繁体   English   中英

比较HIVE中两个表的行

[英]Comparing rows of two tables in HIVE

我想比较HIVE中的两个表。 更具体地说,我想查看table2是否具有table1中没有的任何行,反之亦然。 到目前为止,我有这个:

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;

但这只会检查PERS_KEY。 如何检查整个表是否在一个表中,而不是在另一表中?

您可以根据pers_key进行检查。 但是,我不确定为什么要比较整行。

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM