Reputation: 13
I have tables with the same columns but the values are not all the same. I want to see the values from the columns that dont exists in table 1 but exists in table 2.
it works with:
select *
from table_1
where not exists (select * from table_2 where table_1.xxx = table_2.xxx)
and I join the rest of the columns on each other.
But isn't there a faster way then join every column in the not exists?
Upvotes: 1
Views: 348
Reputation: 3062
Your question says "I want to see the values from the columns that dont exists in table 1 but exists in table 2", however your code example is getting you all rows in table_1
where the same row doesn't exist in table_2
. So, not knowing which one you want, I present you with this solution, which gives you what you asked for first. If you want it the other way around, swap the table names:
select * from table_2
minus
select * from table_1
Caveats:
Upvotes: 1
Reputation: 13
Thanks! EXPECT doesnt work for me (using Oracle) but instead i should use MINUS. That worked! TY!
Upvotes: 0