码迷,mamicode.com
首页 > 数据库 > 详细

mysql笔记--group by,limit用法

时间:2017-10-22 00:32:39      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:gif   nbsp   使用   联合   concat   select   分页   mysq   open   

table:
id tag status
1   a     0
2   b      0
3    c     1
4    d    1


一、group by用法
    1.与count 联合计数
           select status,count(*)
          from table
           group by status

status count(*)
0 2
1 2
2.与 group_concat联合使用 select status,group_concat(tag) as tag from table group by status
status tag
0 a,b
1 c,d
技术分享
二、limit用法
    1.分页
        设页数为page ,每页记录为a

      select *
      from table    
      limit (page-1)*a
View Code

 

mysql笔记--group by,limit用法

标签:gif   nbsp   使用   联合   concat   select   分页   mysq   open   

原文地址:http://www.cnblogs.com/fwdqxl/p/7706848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!