【问题标题】:Comparing rows of two tables in HIVE比较 HIVE 中两个表的行
【发布时间】:2015-07-31 19:42:52
【问题描述】:

我想比较 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。如何检查整行是否在一个表中而不是另一个表中?

【问题讨论】:

    标签: sql hive compare left-join hiveql


    【解决方案1】:

    您可以根据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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-25
      • 2015-10-26
      • 1970-01-01
      • 2018-10-13
      • 2020-03-09
      • 1970-01-01
      • 2016-06-01
      • 1970-01-01
      相关资源
      最近更新 更多