If UNION ALL
is an addition in T-SQL. What is the equivalent of subtraction?
For example, if I have a table PEOPLE
and a table
When I compare tables looking for data that isn't in one that is in the other I typically use SQL Division.
select *(or selected matching field)
from tableA as A
where not exist
(select *(or selected matching field)
from tableB as B
where A.key = B.key)
This query will return the results that are in tableA that are not in through the process of division.
select *(or selected matching field)
from tableA as A
where exist
(select *(or selected matching field)
from tableB as B
where A.key = B.key)
This query will return all the rows of data that match in both tables therefore if there is a row data that is in tableA that isn't in tableB that row of data will not be retrieved.