I’ve got a page that builds up a really long query depending on $_POST variables. The reason I’m trying to do this without MySQL’s OR is because I’d have to restate the entire query just to alter one small parameter at the end, which seems like a waste of resources.
This is my pseudo-query:
SELECT * FROM names WHERE
person = '$var1' AND
place = '$var2' AND
location_a = '$var3' AND
location_b = '$var3'
If I were to use OR, this fat ugly query would be:
SELECT * FROM names WHERE
person = '$var1' AND
place = '$var2' AND
location_a = '$var3' OR
person = '$var1' AND
place = '$var2' AND
location_b = '$var3'
Is there a way to search both location_a and location_b for $var3 without using OR?
Use parantheses:
Actually I don’t get your question. You don’t have to restate your whole query. Maybe you show your code? And what’s so bad about
OR? Just use parantheses.