Simple Search

I am developing a simple keyword search using php and mysql and I am facing problem while using “AND” and “PARENTHESIS” advanced search where user inputs the query. I developed following sql query:
Select * from Page LEFT JOIN Page_Tag LEFT JOIN Tag where((name=“events” and name=“news”) or name=“local”)

I am not getting the answer of the “and” operation whereas “or” operation works properly.

And in parenthesis search, how do i parse input.

that’s never going to be true, ever (and i think you know this already, right?)

the same column value cannot possibly be equal to two different things at the same time

you are going to have to re-think your strategy

try to make an inner join ad this might solve your problem

Looks like you want all the pages tagged either (events and news) or just local. Is that correct? Posting the create tables would help.

Yes, that is what I want.

From your query I can only grasp that there is a column named name inside the Page_Tag table which is just about worthless. The create tables are needed.

Edit: Besides that every row of the Page table is being joined on every row of the Page_Tag table, which I don’t believe is what your after. I would assume where is something like page_id inside the table Page_Tag table that relates a tag to a page. If so please clearly define which column that is. Also it might be worth considering using a m:n relationship here rather then a 1:m relationship, unless there is a table called Tag somewhere just not part of the query.