[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SQL syntax correction

Posted on 2004-10-03
1
Medium Priority
?
472 Views
Last Modified: 2008-03-10
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
Comment
Question by:zachvaldez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 500 total points
ID: 12212997
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question