Hive 中的 NOT EXISTS / NOT IN 子句

时间:2021-07-26 21:31:47

标签: hive hql hiveql

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

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

1 个答案:

答案 0 :(得分:0)

在 hive 中,您可以使用 left join 来消除不存在的类型子句。如果你分享你的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 中。

相关问题