SQL关键字的执行顺序

1.Mysql执行顺序,即在执行时sql按照下面的顺序进行执行:

from
on
join
where
group by
having
select
distinct
union
order by

2.Mysql语法顺序,即当sql中存在下面的关键字时,它们要保持这样的顺序:

select[distinct]  
from  
join(如left joinon  
where  
group by  
having  
union  
order by  
limit  

groupby:groupby要和聚合函数一起使用

union:完全是对select的结果进行合并(默认去掉重复的记录)(想保留重复记录使用union all)

posted @ 2019-08-26 09:03  DiYong  阅读(2618)  评论(0编辑  收藏  举报