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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can change the top line to SELECT * instead of SELECT Product_ID
Delete from FROM Product_Categories where (Category_ID = 0) and (select count(Category_ID) from Product_Categories where Category_ID <> 0) > 1
ASKER
ty