insert into where not exists in hive
Asked Answered
M

1

2

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.

Mccain answered 6/1, 2014 at 14:7 Comment(0)
D
3

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
Dude answered 7/1, 2014 at 1:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.