Mysql 语句执行顺序
一、Mysql 语法顺序select[distinct]fromjoin(如left join)onwheregroup byhavingunionorder bylimit二、Mysql执行顺序fromonjoinwheregroup byhavingselectdistinctunionorder by注:1)使用distinct要写在所有要查询字段的前面,后面有几个字段,就代表
·
一、Mysql 语法顺序
select[distinct]
from
join(如left join)
on
where
group by
having
union
order by
limit
二、Mysql执行顺序
from
on
join
where
group by
having
select
distinct
union
order by
注:
1)使用distinct要写在所有要查询字段的前面,后面有几个字段,就代表修饰几个字段,而不是紧随distinct的字段;
2)group by执行后(有聚合函数),group by后面的字段在结果中一定是唯一的,也就不需要针对这个字段用distinct;
更多推荐
已为社区贡献2条内容
所有评论(0)