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)