Click to See Complete Forum and Search --> : SQL query


b_cochofel
May 6th, 2003, 09:31 AM
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???

M Owen
May 6th, 2003, 09:41 AM
Yes. Use parentheses to set your precedence order ... Just as you did in your example:cool:

antares686
May 7th, 2003, 06:24 AM
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.