문제

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