MySql中Group By和Order By使用的注意事项!

MySql中Group By和Order By使用方式和MsSql有一点小区别

Group By 完全一样,如:

select zw as title,count(*) as id from jzxx  group by zw

此语句能成功执行,但是加 Order by时注意,要在Order by排序的聚合函数上加 ``,如果有良好的编程习惯这个问题就不会出现了!在MsSql里都加上[],在MySql里都加上``能减少很多问题

 

`` 是挨着数字键1那个标点符号!

select zw as title,count(*) as id from [!db.pre!]ecms_jzxx  group by zw order by 'count(*)' desc limit 16

你可能感兴趣的:(group by)