Hello,
do I do this in a mysql query:
SELECT * FROM table WHERE ((c1=x & c2=a) or (c1=y & c2=a))
beats me!!
Joost
SELECT * FROM table WHERE (c1='x' AND c2='a') OR (c1='y' AND c2='a');
Hi,
I think the following two are the same and slightly shorter:
SELECT * FROM table WHERE c2='a' AND (c1='x' OR c1='y')
or
SELECT * FROM table WHERE c2='a' AND c1 IN ('x','y')
But are they faster ?
Thomas
well, the mysql documentation says, that WHERE (c1='x' AND c2='a') OR (c1='y' AND c2='a')
get's optimised to WHERE c2='a' AND (c1='x' OR c1='y')
so i think it's faster 🙂