当前位置:Gxlcms > 数据库问题 > mysql获取表中数据行数

mysql获取表中数据行数

时间:2021-07-01 10:21:17 帮助过:35人阅读

SELECT 2 count(1) AS count 3 FROM 4 table_name;

执行结果

技术分享图片

获取两个表的行数

使用union组合每个select查询的结果集

例如,要在单个查询中获取customersorders表的行数

 1 SELECT 
 2     ‘customers‘ tablename, 
 3      COUNT(1) rows
 4 FROM
 5     customers 
 6 UNION 
 7 SELECT 
 8     ‘orders‘ tablename, 
 9      COUNT(1) rows
10 FROM
11     orders;

运行结果

技术分享图片

获取数据库中所有表的行数

1 SELECT 
2     table_name, 
3     table_rows
4 FROM
5     information_schema.tables
6 WHERE
7     table_schema = ‘dbname‘
8 ORDER BY table_rows desc;

运行结果

技术分享图片

 

mysql获取表中数据行数

标签:row   class   com   order   sel   border   查询   alt   info   

人气教程排行