I’m looking to count the amount of fields in 5 tables and display a result. I currently do this for a single table
$variable = mysql_num_rows(mysql_query("SELECT id FROM table1"));
What is the most efficient way to include and count all id from table2, table3, table4 and table5?
Thanks
Use
UNION ALLto combine theSELECTqueries on all the tables to get the total number of IDs from all the tables. UseUNIONinstead to get total number ofdistinctIDs from all the tables.