Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Help 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
I need a query that will return all records that:

NOT field1 = 'a'

AND

field2 = '1' OR field2 = '2' OR field2 = '3'

AND (here is the problem)

if field1 = 'b' I wonly want the records where

field2 = '1' OR field2 = '2'

[conehead]
 
select ...
where (field1 = 'b' and (field2 = '1' OR field2 = '2'))
or(field1 <> 'b' and (field2 = '1' OR field2 = '2' OR field2 = '3'))
..I think!
 
Katy44,

Your query would also return where Field1 = 'a'.

TCH,

Try changing the last part of Katy44's query to this:

or(field1 NOT IN ('a', 'b')
and (field2 = '1' OR field2 = '2' OR field2 = '3'))

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top