I have a table A
itemid itemname itemgroup
1 item1 group1
2 item2 group1
3 item3 group1
and a table B
itemid itemname itemgroup invid
1 item1 group1 1
3 item3 group1 1
In my case table B
is a subset of table A
or table A
is a superset of table B
(Its a table of items already inventoried). Is there a way to get a list of records of group1
from table A
not present in table B
? Not sure if there is a set operation to get records from super set not contained in the subset (mutual exclusion)?
Currently I am using the following representational query. Is this the right way of accomplishing this? I am currently working in SQL server, but would appreciate answers pertaining to Oracle and MySQL as well.
SELECT itemid, itemname, itemgroup
FROM tableA
WHERE itemid NOT IN (SELECT itemid
FROM tableB
WHERE invid = parameter)