SQL关键字的执行顺序
1.Mysql执行顺序,即在执行时sql按照下面的顺序进行执行:
from on join where group by having select distinct union order by
2.Mysql语法顺序,即当sql中存在下面的关键字时,它们要保持这样的顺序:
select[distinct] from join(如left join) on where group by having union order by limit
groupby:groupby要和聚合函数一起使用
union:完全是对select的结果进行合并(默认去掉重复的记录)(想保留重复记录使用union all)