Skip to content
Advertisement

Compare two tables via the three tables SQL

I plan to compare two tables via the three table. my query is as the following

if the count is zore, then the tableA and TableC match, otherwise, these two tables do not match

Table sample

It takes a long time to run the query. Do we have a way to compare tableA and tableC fast?

Question: How to compare tableA and tableC?

Advertisement

Answer

You don’t need a FULL JOIN here, you can just join the first two tables, then EXCEPT the third.

Note that EXCEPT implies DISTINCT so if you want the number of rows extra in table_A then you need to use WHERE NOT EXISTS

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