Not in

  • Thread starter samotek via AccessMonster.com
  • Start date
S

samotek via AccessMonster.com

I cannot build my query with the Not criteria.Can you help me ? When i write
fo example for customerid <>1720 then customer 1729 does not appear indeed
in the query. But when i write <>1720 Or <>35 nothing ahppens and even
custoemr 1720 also appears.What is wrong with my query ?
 
A

Allen Browne

If you use criteria of:
<>1720 Or <>35
customer 1720 meets the criteria (because it's different to 35), and so does
customer 35 (because it's different to 1720.) The only thing that does not
meet the criteria would be a record where the customer id is null.

To exclude both values, use:
<> 1720 AND <> 35

If you may have more to exclude, you might prefer:
NOT IN (1720, 35)
 
R

Rob Parker

If you're writing this as SQL, you must repeat the field that the condition
applies to. Something like :

WHERE customerid <> 1720 OR customerid <> 35

Or you could use a Not In construction:

WHERE customerid Not In (1720, 35)

If you're trying to enter this in the query design grid, enter each OR
condition in a separate row in the Criteria section.

HTH,

Rob
 
Top