多表查询a
多表查询:会出现笛卡尔乘积,用where emp.dept_id = dept.id;
将两个相等,如下图所示:

左连接和右连接和内连接:

内连接:
隐式内连接select * from emp e,dep d where e.dept.id = dept.id
显式内连接 select * from emp e inner join dep on dept.id = e.dept.id
左外连接:select d.*,e.* from emp e left outer join dept d on e.dept_id = d.id
右外连接:select d.*,e.* from emp e right outer join dept d on e.dept_id = d.id
自连接:可以是内连接也可以是外连接

联合查询union:
union all是将所有记录都查询出来
union时将所有记录查询出来在去重
多张表的列数要保持一致
子查询:
1.标量子查询:

2.列子查询:一列多行

3.行子查询:

表子查询:



