非常简单的查询

时间:2013-05-05 13:21:42

标签: sql sql-server

我被问到是否有更好的方法来编写此查询,我可以想到没有。请帮忙:

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

1 个答案:

答案 0 :(得分:14)

SELECT bookid,
       bookname
FROM   books
WHERE  bookname IS NOT NULL 

维护原始查询的语义。也许您打算使用AND代替OR

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