Skip to content
Advertisement

Which type of JOIN is used to find not matched data from a table?

Is the mentioned question is right? If yes, what will be the answer for that?

Advertisement

Answer

I think your question is how you can join two tables and find the rows that doesnt have an equivalent on either or both sides.

If yes, you can do an outer join.

If you have two tables T1 and T2 and if you want to find the rows that dont have an equivalent in the table T1, then the below query will join both tables and give you only the rows that are in T1 but not in T2.

    SELECT * FROM T1 LEFT OUTER JOIN T2 ON T1.Key=T2.Key WHERE T2.Key IS NULL;

A full outer join can give you rows that dont have a match on either side.

    SELECT * FROM T1 FULL OUTER JOIN T2 ON T1.Key=T2.Key WHERE T2.Key IS NULL OR T1.Key IS NULL;

If you want a better answer,then improve your question and give sample rows on both tables and the example output that you want.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement