hadoop-hive-关于IN与NOT IN

此为自关联, NOT IN 则需要左外关联,u_sina.user is null;


echo a,sinax,1 >> USER_URL_VAL.txt

echo a,163x,2 >> USER_URL_VAL.txt
echo a,sohu,3 >> USER_URL_VAL.txt
echo b,sinax,4 >> USER_URL_VAL.txt
echo b,haha,5 >> USER_URL_VAL.txt
echo a,sinoix,6 >> USER_URL_VAL.txt

create table user_url_val (user string, url string, val string) row format delimited fields temporary by ','; 

load data local inpath '/tmp/USER_URL_VAL.txt' into table user_url_val;  

select * from user_url_val u join
(select user from user_url_val where url='163x') u_sina
on u.user=u_sina.user
where u.url='sinax';

a sinax 1 a


select * from user_url_val u left outer join 
(select user from user_url_val where url='163x') u_sina
on u.user=u_sina.user
where u.url='sinax' and u_sina.user is null;

b sinax 4 NULL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值