准备数据
2,b
3,c
4,d
7,y
8,u

2,bb
3,cc
7,yy
9,pp
建表:
create table a(id int,name string)
row format delimited fields terminated by ',';

create table b(id int,name string)
row format delimited fields terminated by ',';
导入数据:
load data local inpath '/root/hivedata/a.txt' into table a;
load data local inpath '/root/hivedata/b.txt' into table b;

inner join 只打印能匹配上的数据,没有匹配上的不输出

 select * from a inner join b on a.id =b.id;

大数据学习——关于hive中的各种join

left join 

 select * from a left join b on a.id=b.id;

大数据学习——关于hive中的各种join

 

 right join

select * from a right join b on a.id=b.id;

大数据学习——关于hive中的各种join

 

full outer join

select * from a full outer join b on a.id=b.id;

大数据学习——关于hive中的各种join

 

 left outer join

大数据学习——关于hive中的各种join

left semi join

select * from a  left semi join b on a.id=b.id;

相当于
 select * from a where a.id exists(select b.id from b); 在hive中效率极低

大数据学习——关于hive中的各种join

 

相关文章:

  • 2021-09-27
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2021-11-02
  • 2022-01-18
  • 2021-05-15
  • 2021-09-28
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-10-08
  • 2021-12-16
相关资源
相似解决方案