mysql笔记--group by,limit用法


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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM