SQL语句除外

时间:2013-10-08 05:09:31

标签: sql

我想知道库存数量为5或更多的产品,供应商,类别和库存数量的名称,除了Spaulding提供的那些产品。然后按供应商排序然后按库存数量。

这是我的代码,问题是它只显示包含5个或更多库存数量的商品:

SELECT      ProdName, ProdSupplier, ProdCategory, ProdInvQty
FROM        PRODUCT
WHERE       ProdInvQty  >= 5
AND             ProdSupplier = 'Spaulding'

ORDER BY    ProdSupplier, ProdInvQty;

2 个答案:

答案 0 :(得分:2)

根据你的模糊描述,我认为你想要(编辑)

SELECT      ProdName, ProdSupplier, ProdCategory, ProdInvQty
FROM        PRODUCT
WHERE       (ProdInvQty  >= 5 
OR          ProdSupplier = 'Spaulding')

ORDER BY    ProdSupplier, ProdInvQty;

答案 1 :(得分:0)

SELECT      ProdName, ProdSupplier, ProdCategory, ProdInvQty

FROM        PRODUCT

WHERE       ProdInvQty  >= 5

AND         ProdSupplier NOT LIKE 'Spaulding'

ORDER BY    ProdSupplier, ProdInvQty;