Hi Friends,

Last week, I was in an assignment and one of the guys asked this question: “How to Return non matching records from two tables?”

So, here goes the scenario. There are two tables, say, Table1 & Table2 and both of them have a column, say col1. And you want to return records that are unique to each table (non-matching) based on col1.

Table1

Col1

AAA

BBB

CCC

Table2

Col1

AAA

BBB

ZZZ

So, you need to write a query that returns CCC & ZZZ.

Here is the solution:

There are other techniques too to solve the above problem. Do post comments and let the readers know about your solution.