Query assistance

New Here ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

I took this from Access and have used IS NOT.  I took everything out except for "Wal-mart", Changed to Wal-Mart and 'Wal-mart'.  Nothing works unless I take the entire Where clause out.  Any help would be appreciated.

 

WHERE ShipToName NOT ("Wal-Mart" OR "GCC Belvidere IL") AND FOB ="delivered" AND ShipToID Not ("MAN-002" OR "OXN-001" OR "WAT-001")))

Views

56

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

You say you "took this from Access". What's not clear is what db you are running it against now. Is it Access? Mysql? Sql server? Something else?

 

Note that standard sql uses <> for not equal (rather than "not").

 

Also, most dbs require using single quotes rather than double quotes for strings.

 

Can you let us if those pointers help? Or again tell us the dbms you're using. 


/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

LATEST

MS SQL.  Sorry about that.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

As Charlie says the databsae you are using is important to know but your query in SQL that is applicable to most DB's could use lists and look something like 

 

WHERE ShipToName NOT IN ('Wal-Mart', 'GCC Belvidere IL') AND FOB = 'delivered' AND ShipToID NOT IN  ('MAN-002', 'OXN-001', 'WAT-001')

 

The parentheses is your where clause do not match up, you have extra on the end, so is there more than you posted here?

 

 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines