Starting with 2 tables, I want to get all rows with value in a certain column(cName) that is present on 1 table but not the other. I want to do this for both tables. I found a solution to use LEFT JOIN which gives me solution for 1 of the tables and I used UNION to combine. Is this a good way to do this or is there a better way?
select * from College C1 LEFT JOIN myTestTable T1 on C1.cName = T1.cName where T1.cName IS NULL UNION select * from myTestTable T1 LEFT JOIN College C1 on T1.cName = C1.cName where C1.cName IS NULL
Advertisement
Answer
You can use full join
with a where
:
SELECT * FROM College C1 FULL JOIN myTestTable T1 ON C1.cName = T1.cName WHERE T1.cName IS NULL OR C1.cName IS NULL;