I'm trying to produce a query where several things have to be true, before anyone jumps in with AND and OR its not that simple.
SELECT * FROM table WHERE something='1' OR something='2' AND thing='foo1' OR
thing='foo2'
The problem is that all results to that must contain only those rows where something is 1 or 2, AND where thing foo1 or foo2.
Currently of course it gives me all results where any of them are correct, I want something like the below (which I can't use due to an obvious parse error)
Originally trying...
$query = mysql_query("SELECT * FROM table WHERE something='1' OR something='2' AND thing='foo1' OR
thing='foo2'",$db);
With brackets trying
$query = mysql_query "SELECT * FROM table WHERE (something='1' OR something='2') AND (thing='foo1' OR
thing='foo2')",$db;
Thanks for any help anyone!