(转)Hive使用LEFT OUTER JOIN 实现not in 子句

link:http://chiyx.iteye.com/blog/1530981

当前HIVE 不支持 not in 中包含查询子句的语法,形如如下的HQ语句是不被支持的: 

查询在key字段在a表中,但不在b表中的数据 

Sql代码  收藏代码
  1. select a.key from a where key not in(select key from b)  



可以通过left outer join进行查询,(假设B表中包含另外的一个字段 key1 

Sql代码  收藏代码
    1. select a.key from a left outer join b on a.key=b.key where b.key1 is null  

       

原文地址:https://www.cnblogs.com/tangtianfly/p/3078018.html