I want to fetch the unmatching records from two table in SQL, the table structure is as follows:
Table1
Id Name
1 Prashant
2 Ravi
3 Gaurav
5 Naween
7 Sachin
Table2
Id Name
1 Prashant
2 Ravi
4 Alok
6 Raja
The output I want is
Id Name
3 Gaurav
4 Alok
5 Naween
6 Raja
7 Sachin
What will be the query to fetch the required output in SQL?
I think joeslice’s answer will only give half the results. You need to union the other table. Alternatively, you could do a full outer join.