hive的简单的关联查询

2022-01-25  本文已影响0人  你的努力时光不会辜负

CREATE TABLE testdb1 (
id int,
name string,
age int,
pdate string
)
WITH (format = 'ORC')

CREATE TABLE testdb2 (
id int,
name string,
pdate string
)
WITH (format = 'ORC')

insert into testdb1 values (1,'Alice',24,'20210529')
insert into testdb1 values (2,'Bob',16,'20210529')
insert into testdb1 values (3,'Tom',23,'20210529')
insert into testdb1 values (4,'Lili',21,'20210529')
insert into testdb2 values (1,'Alice','20210529')
insert into testdb2 values (3,'Bob','20210529')
insert into testdb2 values (6,'Zidane','20210529')

select *
FROM
testdb1 a inner join testdb2 b
on
a.name = b.name

select *
FROM
testdb1 a left join testdb2 b
on
a.name = b.name

select *
FROM
testdb1 a right join testdb2 b
on
a.name = b.name

select *
FROM
testdb1 a full join testdb2 b
on
a.name = b.name

来源:https://blog.csdn.net/fangfanglovezhou/article/details/117364145

上一篇下一篇

猜你喜欢

热点阅读