I'm not getting the expected result from an SQL query

midnight_ashes

New Member
I'm developing a search function for a website. I have a table called keywords with two fields id and keyword. I have two separate search queries for AND and OR. The problem is with the AND query. It is not returning the result that I expect.The printed SQL is : \[code\]SELECT COUNT(DISTINCT tg_id) FROM tg_keywords WHERE tg_keyword='keyword_1' AND tg_keyword='keyword_2'\[/code\]The count returned is 0, while if I perform the same SQL with OR instead of AND the count returned is 1. I expected the count to be 1 in both cases, and I need it to be this way as the AND results will take priority over the OR results.Any advice will be much appreciated.ThanksArchie
 
Back
Top