How does mysql query the number of rows in a table
Editor to share with you mysql how to query the number of rows of the table, I hope you will gain something after reading this article, let's discuss it together!
Mysql query table row number method: 1, use the "SELECT" statement to query all the data in the specified table; 2, use the COUNT () function to count the number of rows of the query results, the syntax is "SELECT COUNT (*) FROM table_name;".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Number of rows in the mysql query table
1. Get the number of rows in a single table
SELECT COUNT (*) FROM table_name
two。 Get the number of rows for multiple tables (you can use the UNION operator to combine the result set returned by each SELECT statement)
SELECT 'tablename1' tablename, COUNT (*) rowsFROM table_name1UNION SELECT' tablename2' tablename, COUNT (*) rowsFROM table_name2
3. Get the number of rows of all tables in a database (the information_schema method is sometimes inaccurate)
Use information_schema;select table_name,table_rows from tables where TABLE_SCHEMA = 'db.name' order by table_rows desc; after reading this article, I believe you have a certain understanding of "mysql how to query the number of rows in the table". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!