多表查询:
连接查询:
1.交叉连接:select * from 表1 cross join 表2;
select * from 表1,表2;
*2.内连接:inner join(inner可以省略)
显示内连接:使用关键字
select * from 表1 inner join 表2 on 关联条件;
隐式内连接:没有使用关键字
select * from 表1,表2 where 关联条件;
*3.外连接:outer join(outer可以省略)
左外连接:select * from 表1 left outer join 表2 on 关联条件;
以左表为基准,根据关联条件匹配右表的数据.
右外连接:select * from 表1 right outer join 表2 on 关联条件;
*子查询:查询语句条件依赖另一个查询语句.
1.带in
2.带exists
3.带any
4.带all