-
SQL query
Hi,
I want to know if it's possible to use together bot AND and OR operators in a SQL statement, and if it is, how?
It's for an advanced search, and some fields work has a OR, and the others work has a AND.
Ex: Field1, Field2, Field3, Field4
Field1=text AND Field2=text AND (Field3=text OR Field4=text),
is this possible???
-
Yes. Use parentheses to set your precedence order ... Just as you did in your example:cool:
-
If you do without the parenthsis like this
Field1=text AND Field2=text AND Field3=text OR Field4=text
it would be ran as though you did this
(Field1=text AND Field2=text AND Field3=text) OR Field4=text
so it is better to qualify your sections to ensure the right outcome.