前言
Hive-3.1.2版本支持6种join语法。分别是:inner join(内连接)、left join(左连接)、right join(右连接)、full outer join(全外连接)、left semi join(左半开连接)、cross join(交叉连接,也叫做笛卡尔乘积)。
一、Hive的Join连接
数据准备: 有两张表studentInfo、studentScore
create table if not exists studentInfo
(
user_id int comment '学生id',
name string comment '学生姓名',
gender string comment '学生性别'
)
comment '学生信息表';
INSERT overwrite table studentInfo
VALUES (1, '吱吱', '男'),
(2, '格格', '男'),
(3, '纷纷', '女'),
(4, '嘻嘻', '女'),
(5, '安娜', '女');
create table if not exists studentScore
(
user_id int comment '学生id',
subject string comment '学科',
score int comment '分数'
)
comment '学生分数表';
INSERT overwrite table studentScore
VAL