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
Solved

SQL syntax correction

Posted on 2004-10-03
1
462 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
1 Comment
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 125 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL, How to do aggregation on extracting field and range band field? 2 30
SQL Query 2 31
SQL Server Configuration Manager WMI Error 11 16
SQLCMD Syntax 2 13
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

809 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