好的,所以这就是我的需要:
假设我们有一张桌子,例如A
并且需要获取行数。
在这种情况下,我们SELECT COUNT(*) FROM A
。
现在,如果我们有3个不同的表,请说A
,B
和C
。
如何获取所有这三个行中的总行数?
答案 0 :(得分:3)
Select (select count(*) from a) +
(select count(*) from b) +
(select count(*) from c);
如果每次只有3个计数,是最简单的方法。
答案 1 :(得分:1)
尝试这样的事情:
SELECT
((select count(*) from demo1) +
(select count(*) from demo2) +
(select count(*) from demo3)) as Tbl3;
Sql fiddle:http://sqlfiddle.com/#!2/d439f8/5
答案 2 :(得分:0)
select SUM(cnt) from (
select count(*) as cnt from A
union
select count(*) as cnt from B
union
select count(*) as cnt from C) as T