I have the following two tables:
ITEM (Item#, Item_Name, Unit_Price) ORDER_ITEM (Order#, Item#, Qty)
Now, how do I list the items that have never been ordered by using the MINUS operator?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
This is a bit long to add as a comment to @CalZ answer so I create another answer:
select item#, Item_Name from item minus select i.item#, i.Item_Name from item i join order_item oi on i.item# = oi.item#
in the second leg of the minus, we construct a new relation using a join between item and order_item that we can subtract from item.