Chatrapati Posted August 20, 2013 Share Posted August 20, 2013 how to COUNT the total rows in 10 tables, example :friendshipsms[500] how to count the rows in 10 tables? i tried this but did'nt work? $sql="SELECT COUNT(*) FROM table1,table2,table3,table4,table5"; $result=mysql_query($sql); $numrows=mysql_fetch_row($result); echo $numrows[0]; Link to comment https://forums.phpfreaks.com/topic/281386-how-to-count-the-total-rows-in-10-tables/ Share on other sites More sharing options...
Barand Posted August 20, 2013 Share Posted August 20, 2013 You can query the "Tables" table in the "Information_schema" database. $db = new mysqli(HOST, USERNAME, PASSWORD, 'information_schema'); $sql = "SELECT table_name, table_rows FROM tables WHERE table_schema = 'yourDatabaseName' AND table_name IN ('table1', 'table2')"; $db->query($sql); Link to comment https://forums.phpfreaks.com/topic/281386-how-to-count-the-total-rows-in-10-tables/#findComment-1445960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.