from
on
join
where
group by
having
select
distinct
union
order by
这个顺序其实是很重要,用的好能够提升你的查询效率,比如说以下语句
1:select A.ID as AID, B.ID as BID from A left join B on A.ID = B.ID where B.ID<3 ;
2:select A.ID as AID, B.ID as BID from A left join B on A.ID = B.ID and B.ID<3 ;
看似2个语句是没有区别的,但是由于1是from,on,join;2是from,join,where由于左联会保证左边数据完全存在所有数据结果就不一样了。如果用的是join虽然结果没有区别,但是where筛选的范围变了,所以肯定是用on比较快。