Think before you speak, read before you think.

mysql count用法

其实也是使用了select命令

查询表中有多少条记录

select count(*) from table-user;

上面使用了count(*)会使整张表加载到内存,查询效率较低,毕竟是统计数量,使用count(ID)即可,如

select count(ID) from table-user;

用户男女数量统计

select sex,count(ID) from table-user GROUP BY sex;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *