Jump to content

[SOLVED] SQL Order Of Operations in "AND" and "OR" operators


Recommended Posts

I have a php script that generates search querys. The generated query looks like this when i enter the search term "test", and "search":

 

SELECT title,description,link FROM search WHERE title like '%test%' or description like '%test%' or link like '%test%' and title like '%search%' or description like '%search%' or link like '%search%'

 

My problem is that it always returns a result even if the second AND statement is evaluated false. I have talked to a few people about this and they said my "order of operations" are wrong in the query. Can someone explain how i could do the query different to get the desired results?

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.