Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Simple query question

Author  Topic 

dwops
Starting Member

1 Post

Posted - 2002-07-24 : 15:14:43
hi, can anyone help me with simple sql query question.

I need to know the syntax for grouping ANDs and ORs together...
as in:

SELECT * FROM table WHERE (condition1 OR condition2) AND condition3

or

SELECT * FROM table WHERE
(condition1 AND condition2) OR (condition3 AND condition4)

Basically, I just need to know what to use (parens, brackets, commas etc) and i need to know where to place them.

Thanks in advance for any help!

Dwops

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-07-24 : 17:24:12
Use parenthesis as in your example.

E.g.

select * from t where (c1 = 47 or c2 = 11) and c3 = 'Magdur'

Go to Top of Page
   

- Advertisement -