mysql查看table的记录数目

有时候,只是想查看某个table中有多少个条记录,并不是想看所有的结果。

这个时候

select * from [tablename]

就显得有点杀鸡用牛刀的感觉了。

我们可以用

select count(*) as total_record from  [tablename];

例如:

select count(** as total_record from students;

+————–+
| total_record |
+————–+
|           14 |
+————–+
1 row in set (0.00 sec)

就会显示有14条记录。

我们还可以加上条件:

select count(*) as total_record from  [tablename] where [condition];

例如:

select count(** as total_record from students where grade=’2′;

完。

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

Leave a Reply

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