Domanda

I have two identical tables.

I want to run a select count(*) query on both the table together at any time and want to get total no of messages present in both of them at that time stamp.

suppose both has 50 msgs then I should get 100 as output regardless the no of common data present in the two table.

Can any one help me?

Nessuna soluzione corretta

Altri suggerimenti

Since both tables are identical,

SELECT COUNT(*) as TotalCount 
FROM
(SELECT * FROM Table1
UNION
SELECT * FROM Table2) AAA

in Addition to what Raging Bull has you could also have:

select SUM(counter) as sum from 
(select count(*) as counter from t1 union
select count(*) as counter from t2) as t;

Sql fiddle

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top