表A 的 id 总行数
表B 的 id 总行数
表C 的 id 总行数
表D 的 id 总行数然后相加的值select count(A.id)+count(B.id)+count(C.id)+count(D.id) from A,B,C,D ?????? 此式错误。
表B 的 id 总行数
表C 的 id 总行数
表D 的 id 总行数然后相加的值select count(A.id)+count(B.id)+count(C.id)+count(D.id) from A,B,C,D ?????? 此式错误。
(select count(id) as 行数 from a
union all
select count(id) as 行数 from b
union all
select count(id) as 行数 from c
union all
select count(id) as 行数 from d
)
count(1)
from
(select count(id) as num from a
union all
select count(id) as num from b
union all
select count(id) as num from c
union all
select count(id) as num from d
)t
(select count(ID) from A)+(select count(ID) from B)+(select count(ID) from C)+(select count(ID) from D)
select count(1) as num from A
union all count(1) from b
union all count(1) from c
union all count(1) from d) a
select (select count(*) from a)+(select count(*) from b)+select (select count(*) from c)+(select count(*) from d)
union all
select 1 from b
union all
select 1 from c
union all
select 1 from d
select @@rowcount
(select count(id) as 行数 from a
union all
select count(id) as 行数 from b
union all
select count(id) as 行数 from c
union all
select count(id) as 行数 from d
) tt
下面就產生4條記錄
sum才對
FROM (SELECT COUNT(id) AS 行数
FROM A
UNION ALL
SELECT COUNT(id) AS 行数
FROM B
UNION ALL
SELECT COUNT(id) AS 行数
FROM C
UNION ALL
SELECT COUNT(id) AS 行数
FROM D) tt
只有这个是成功的。无语。。