I have two tables, t1 and t2, with the same columns (id, desc) and data. But one of the desc columns may have different data for the same primary key, id.
I want to select all of these rows from these two tables so that t1.desc! = T2.desc
select a.id, b.desc
FROM (SELECT * FROM t1 AS a
UNION ALL
SELECT * FROM t2 AS b)
WHERE a.desc != b.desc
For example, if t1 has (1, 'aaa') and (2, 'bbb') and t2 has (1, 'aaa') and (2, 'bbb1'), then the new table should have (2, 'bbb' ) and (2, 'bbb1')
However, this does not work. Please let me know where I am going wrong and how to do it right.
source
share