sql语句优化
正常sql语句顺序:select-from- join on- where-group by-having-order by -limit
join语句:inner join 取公共有部分
left join 取左表的独有和两表的共有
right join 取右表的独有和两表的共有
select *from a left join b on a.key=b.key where b.key is null ,取左表独有
select *from a left join b on a.key=b.key where a.key is null ,取右表独有
full outer join 取所有
full outer join a.key is null b.key isnull,取两表独有
mysql 可以使用 union 连接两次查询