Mysql – How to get sum of the rows of 3 tables

MySQL

I have 3 tables and I want to know with one query sum of row's number in 3 tables

I tried 2 different queries but it they give only the number of rows each table and I c'ant read with,

     return int.Parse(cmd.ExecuteScalar().ToString());

the sum of rows of 3 tables.

I must read by reader and get the sum

Here are 2 queries I used:

    SELECT  (
        SELECT COUNT(*)
        FROM   prodbiscuit WHERE status =2
        ) AS count1,
        (
        SELECT COUNT(*)
        FROM   prodganache WHERE status =2
        ) AS count1,
        (
        SELECT COUNT(*)
        FROM   prodmacaron
        ) AS count1
        FROM   dual

And the other query which give the same result:

       SELECT COUNT(DISTINCT nom) as rows FROM prodbiscuit WHERE status=2 

       UNION SELECT COUNT(DISTINCT nom) AS rows FROM prodganache WHERE status=2  

       UNION SELECT COUNT(DISTINCT nom) AS rows FROM prodmacaron

How to get real sum of rows of tree tables with one query?

Should I use absolutely reader ?

Best Answer

http://searchoracle.techtarget.com/answer/Sum-of-two-table-row-counts-as-one-answer

 select ( select count(DISTINCT nom) from prodbiscuit WHERE status =2 )
 + ( select count(DISTINCT nom) from prodganache WHERE status =2 ) 
 + ( select count(DISTINCT nom) from prodmacaron) 
      as total_rows

Finally I've found it at given link