Selecting the union:
select * from table1
union
select * from table1_backup
What is the query to select the intersection?
SELECT *
FROM table1
WHERE EXISTS
(SELECT *
FROM table1_backup
WHERE table1.pk = table1_backup.pk)
works
subqueries?! really?
to get the intersection of table1 and table2:
SELECT * FROM table1, table2 WHERE table1.pk=table2.pk;
In SQL Server intersect
select * from table1 intersect select * from table1_backup
"intersect" is also part of standard SQL.
Inner join gives a different answer.
An intersect on two identical tables a and b can be done in this manner:
SELECT a.id, a.name
FROM a INNER JOIN b
USING (id, name)
select distinct * from (select * from table1 union select * from table1_backup)