insert into where not exists in hive

寵の児 提交于 2020-01-14 05:20:08

问题


I need the hive syntax for this equivalent in ansi sql

insert into tablea
(id)
select id 
from tableb
where id not in (select id from tablea)

so tablea contains no duplicates and only new ids from tableb are inserted.


回答1:


Use left outer join with a filter that the tableA.id is null:

insert overwrite into tableA (id)
select b.id from tableB b left outer join tableA a
 on a.id = b.id
where a.id is null


来源:https://stackoverflow.com/questions/20951703/insert-into-where-not-exists-in-hive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!