Nov 21
  • If you use GROUP BY, output rows are sorted according to the GROUP BY columns as if you had an ORDER BY for the same columns. To avoid the overhead of sorting that GROUP BY produces, add ORDER BY NULL:

    SELECT a, COUNT(b) FROM test_table GROUP BY a ORDER BY NULL;

– 载自 MySQL 手册.

上面说的是, group by 默认会排序, 如果不想这么做, 必须显式声明.

Related posts:

  1. MySQL”海量数据”查询性能分析
  2. 面试IT业界顶尖企业所应该知道的10道题(1)
  3. Linux下编译安装Apache/Lighttpd+PHP+MySQL
  4. MySQL 建立外键约束
  5. Web应用中基于组的用户权限管理在Spring框架下的实现

Written by ideawu at 2008-11-21 19:55:32 | Views: 2988

Leave a Reply

必须登录, 或者浏览器开启JavaScript支持才可以评论!


网站空间,免费试用