Hi, Can't work this one out! When I perform the query below all the results comes back as expected: SELECT title, fkingredienttypeId, pkingredientId, subtitle price, weightType FROM dingredients i WHERE i.title LIKE '%bluefoo%' AND fkIngredientTypeId NOT IN (22,24,26) AND disabled = 0 ORDER BY title Code (markup): However when I add the OR statement (OR i.subtitle LIKE 'bluefoo') it then ignores the two AND statements following which obviously brings results back I don't want to show! Any ideas why this is happening? SELECT title, fkingredienttypeId, pkingredientId, subtitle price, weightType FROM dingredients i WHERE i.title LIKE '%bluefoo%' OR i.subtitle LIKE 'bluefoo' AND fkIngredientTypeId NOT IN (22,24,26) AND disabled = 0 ORDER BY title Code (markup): By the way its a mySQL db and "bluefoo" is the random search term. Any help would be be great! Cheers
use ( ) SELECT title, fkingredienttypeId, pkingredientId, subtitle price, weightType FROM dingredients i WHERE (i.title LIKE '%bluefoo%' OR i.subtitle LIKE 'bluefoo') AND fkIngredientTypeId NOT IN (22,24,26) AND disabled = 0 ORDER BY title Code (markup):
thanks for the rep more info on this: http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html