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?

没有正确的解决方案

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top