Count rows in more than one table?

admin

Administrator
Staff member
Hi
I磎 a newbee to php, mysql and SQL so please forgive me for asking this (probably) simple question, and forgive me for my bad english...

I have some tables in a database and I would like to get a summary of how many rows there are in all my tables all together.
If I have 52 rows in table 1 and 22 rows in table 2 and 43 rows in table 3 I磀 like the result to be 117. OK?

I have no problems counting the rows in ONE table. This is the code I then use:

<?php
$connect=@mysql_connect("localhost","user","");
$databas=mysql_select_db("my_database");
$result=mysql_query("select count(*) AS rows from table_1");
list($rows) = mysql_fetch_row($result);
print $rows;
?>

Now, how do I count the rows in several tables together?

//Jessica
 
Back
Top