astraldust
astraldust

Reputation: 115

Very Simple Query

I have been asked if there is a better way to write this query and I can think of none. Please help:

 select bookid, bookname
   from books
  where bookname not like 'D%' or bookname not like 'F%'

Upvotes: 2

Views: 78

Answers (1)

Martin Smith
Martin Smith

Reputation: 452988

SELECT bookid,
       bookname
FROM   books
WHERE  bookname IS NOT NULL 

Maintains the semantics of your original query. Perhaps you meant to use AND instead of OR

SELECT bookid,
       bookname
FROM   books
WHERE  bookname NOT LIKE '[DF]%' 

Upvotes: 14

Related Questions