mysql数据库查询

Posted god3064371

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql数据库查询相关的知识,希望对你有一定的参考价值。

聚合查询:

sum() max min avg count(*)

select max(aaa) from yyy

select count(bbb) from yyy  //统计某列数据条数

select count(*) from yyy  //统计表数据条数

分页查询:

limt 起始行(从0开始),查询几行,

select * from yyy limit 0,2   

select * from yyy limit 4,2   

查询排序: 

order by desc递减,asc递增

select aaa from yyy order by bbb desc,ccc asc

分组查询:

group by ccc

select ccc,count(*) from yyy group by ccc

分组查询后筛选:

select ccc,count(*) from yyy group by ccc having count(*)>2

 

以上是关于mysql数据库查询的主要内容,如果未能解决你的问题,请参考以下文章