1 数据准备
emp1表:
1 张三 A1
2 李四 A2
3 王五 A3
4 小明 B1
dept1表:
A1 财务
A2 人事
create table if not exists emp1
(
emp_no string
,name string
,dept_no string
)row format delimited fields terminated by '\t';
create table if not exists dept1
(
dept_no string
,dept_name string
)row format delimited fields terminated by '\t';
2 LEFT JOIN(RIGHT JOIN)验证
2.1 LEFT JOIN(RIGHT JOIN)只带ON的HQL
select t1.name,t1.dept_no,t2.dept_no from emp1 t1
left join dept1 t2
on t1.dept_no = t2.dept_no;
张三 A1 A1
李四 A2 A2
王五 A3 NULL
小明 B1 NULL
2.2 LEFT JOIN(RIGHT JOIN)只ON和AND的HQL