• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

SQL syntax correction

I have this sql statement which supposed goal is to select items based on the description field only if they do not have
the word 'Not in" or  "Discontinued" in the beginning of the description field; s in

" Not in the list..." or "Discontinued item..." and so forth

SELECT Publisher,Book,Descrip,Cost, List,pubid,RowLastUpDtByOp,RowLastUpdtDtTi from Books where pubid = '276 ' and(descrip not like 'Not%' or descrip not like 'Discontinued %') order by id

For some reason I still get those data that has 'Not in" or "Discontinued' in the resultset.
Where am I making the mistakes?

0
zachvaldez
Asked:
zachvaldez
1 Solution
 
jdlambert1Commented:
Just change your "or" to "and":

SELECT Publisher,Book,Descrip,Cost, List,pubid,RowLastUpDtByOp,RowLastUpdtDtTi
FROM Books
WHERE pubid = '276 ' AND descrip not like 'Not%' AND descrip not like 'Discontinued %'
ORDER BY id
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now