Hi i have a mysql query with multiple conditions to check, so I’m using () to separate each one, for example:
WHERE (a='string' AND b='string') OR (a='otherstring' AND b='otherstring)
The problem I have is that I have to add a user check, si I don’t know if I have to use () again, for example, is this correct?
WHERE ((a='string' AND b='string') OR (a='otherstring' AND b='otherstring)) AND (id='1')
Thanks!
This will find all records with an id of 1 and where a.string=b.string or a.string=otherstring.
Edit: just for extra clarification:
Basically, anything inside of brackets is equated together for example:
in this example. both clauses in condition 1 have to be met. Condition 2 also has to be met and inside that one,
someCondition HAS to equal anotherConditionas well as one of either of the statements in Condition 3.