how to write subquery and use “In” Clause in Hive

后端 未结 7 1797
滥情空心
滥情空心 2021-01-31 19:49

How can I use In clause in Hive I want to write something like this in Hive select x from y where y.z in (select distinct z from y) order by x; But I am not finding any way o

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 20:29

    assume table t1(id,name) and table t2(id,name)

    listing only those ids from t1 that exists in t2(basically IN clause)

    hive>select a.id from t1 a left semi join t2 b on (a.id=b.id);
    

    listing only those ids from t1 that exists only in t1 but not in t2(basically NOT IN clause)

    hive>select a.id from t1 a left outer join t2 b on(a.id=b.id) where b.id is null;
    

提交回复
热议问题