【问题标题】:NOT EXISTS / NOT IN clause in hive蜂巢中的 NOT EXISTS / NOT IN 子句
【发布时间】:2021-10-02 18:52:57
【问题描述】:

我试图找到如何在 HIVE 中使用 NOT EXISTS / NOT IN 子句,但没有找到 HIVE 必须提供的解决方案。

我基本上需要找到存在于一个表中而不存在于第二个表中的 id,但我找不到跳过它的方法。请指教

【问题讨论】:

标签: hive hql hiveql


【解决方案1】:

在 hive 中,您可以使用 left join 来 detech not exist 类型子句。如果你分享你的sql,我可以更精确。但这里有一些提示。

select 
a.id
from
a
left outer join b on a.id = b.id
left outer join c on a.id = c.id
where
b.id is null  -- make sure data doesn't exist in b
and c.id is not null  -- make sure data exists in c

left join 和 where 子句确保数据存在于表 c 中但不存在于 b 中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-29
    • 2013-02-10
    • 2013-04-17
    • 2016-02-11
    • 2014-12-29
    • 1970-01-01
    • 1970-01-01
    • 2015-07-06
    相关资源
    最近更新 更多