hive中没有except,那么怎么实现sql中except这个排除功能呢(亲测没问题)

1.Hive Sql 不支持 Except 函数
2.我们使用LEFT OUTER JOIN + 字段 IS NULL 来实现,两个表的排除效果
3.先建两个表
create table person1 (name string,age int)
create table person2 (name string,age int)
4.插入数据,这里插入的是两个表中有相交的数据
insert into table test.person1 values(‘曹操’,20);
insert into table test.person1 values(‘郭嘉’,20);
insert into table test.person1 values(‘典韦’,20);
insert into table test.person1 values(‘张辽’,20);
insert into table test.person1 values(‘孙权’,20);
insert into table test.person1 values(‘周瑜’,20);
insert into table test.person2 values(‘刘备’,20);
insert into table test.person2 values(‘关羽’,20);
insert into table test.person2 values(‘张飞’,20);
insert into table test.person2 values(‘赵云’,20);
insert into table test.person2 values(‘孙权’,20);
insert into table test.person2 values(‘周瑜’,20);
5.使用
select a.name,a.age from test.person1 a left outer join test.person2 b on (b.name=a.name) where b.name is null
在这里插入图片描述
最后的执行结果,有没有达到你想要的的结果呢···

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值