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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Criteria syntax question

Status
Not open for further replies.

splint1906

Technical User
Jul 19, 2004
27
US
I have a table with Vendor#, VendorName and Status. The Status field has either OBS (Obsolete), NA (not available) or is blank.

I am trying to write a query that displays all Vendor# when Status field does not equal OBS or NA but, I can't get it to work right. My problem is the WHERE statement. I'm not sure if <>"OBS" is the right syntax.

The SQL is:
SELECT Vendors.VendorCode, Vendors.VendorName, Vendors.VendorUnion
FROM Vendors
WHERE (((Vendors.VendorUnion)<>"OBS" Or (Vendors.VendorUnion)<>"NA"))
ORDER BY Vendors.VendorCode;

 
Code:
SELECT Vendors.VendorCode, Vendors.VendorName, Vendors.VendorUnion
FROM Vendors
WHERE (Vendors.VendorUnion not in("OBS","NA"))
ORDER BY Vendors.VendorCode;

Not sure if this is what you want.
 
splint1906 - You needed to use AND instead of OR for your syntax:

WHERE (((Vendors.VendorUnion)<>"OBS" AND (Vendors.VendorUnion)<>"NA"))

The opposite of "a=b or a=c" (you want records where a equals b or c) is "a<>b AND a<>c" (you want records where a is neither b nor c).

"a<>b OR a<>c" is always TRUE (unless NULLS are involved or b=c).

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top