I want to compare two tables in HIVE. More specifically, I want to see if table2 has any rows that are not in table1, and vice versa. So far I have this:
select count(A.PERS_KEY) from
table1 A left outer join table2 B
on A.PERS_GEN_KEY = B.PERS_KEY
where B.PERS_KEY IS NULL;
But this will only check for the PERS_KEY. How would I check to see if an entire row is in one table but not the other?
答案 0 :(得分:0)
You can check based on pers_key
. However, i am not sure why you would compare the entire row.
select pers_key from table1
where pers_key not in (select distinct PERS_GEN_KEY from table2)
select pers_gen_key from table2
where pers_gen_key not in (select distinct pers_key from table1)