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.
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.