I want to compare two tables that has the same columns but different number of rows. How do I find which rows are unique to each table? I found some join tutorials but it needs primary key to join two tables, my sample tables have no relation to each other.
Sample table:
TableA
Id | Name
1 | Person1
2 | Person2
3 | Person3
4 | Person4
TableB
Id | Name
1 | Person1
2 | Person2
4 | Person4
Sample result:
Id | Name
3 | Person3
Optional result:
Id | Name | Table
3 | Person3 | TableA
This query selects rows from TableA that are not present in TableB plus the rows from TableB not present in TableA, using a UNION statement.