Link to home
Start Free TrialLog in
Avatar of vbnetcoder
vbnetcoder

asked on

SQL deLETE QUERY

This:

SELECT * FROM Product_Categories WHERE Product_ID = '101'

Returns me 2 items one where Category_ID = 0 and another where it is something different then 0

How would I delete all items in the table where  Category_ID = 0 IF there is at least one OTHER item where  Category_ID is NOT 0
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can change the top line to SELECT * instead of SELECT Product_ID
Avatar of jimyX
jimyX

Delete from FROM Product_Categories where (Category_ID = 0) and (select count(Category_ID) from Product_Categories where Category_ID <> 0) > 1
Avatar of vbnetcoder

ASKER

ty