连接查询包括内连接、外连接和交叉连接
inner join 只返回两个表中联结字段相等的行
left join 返回左表中的所有记录和右表中联结字段相等的记录
right join 返回右表中的所有记录和左表中联结字段相等的记录
inner join 自动选择较小的表作为驱动表
left/right join 默认左/右表作为驱动表
内连接
select 表1.列名 from 表1 as 表别名1
inner join 表2 as 表别名2
on 连接条件(表1.列名 = 表2. 列名 and 表2.列名 = “”)
order by 列名
等同于
select 列名 from 表1
where 列名 in (
select 列名 from 表2
where 列名 = “”
)
order by 列名
