把四次的结果union在一起.select * from .... union select * from .... union select * from .... union select * from ....
select sum(A.n)+sum(B.n)+sum(C.n)+sum(D.n) as sum_ABCD from A,B,C,D
恩,谢谢 我后来想到用UNION ALL的 只是查询语句长的啦 UNION ALL 和UNION 有区别吗?
我是这样的 select sum(total) from ( select count(*) total from dept union all select count(*) total from emp1 union all select count(*) total from emp2 union all select count(*) total from emp3) 谢谢大家
union
select * from ....
union
select * from ....
union
select * from ....
from A,B,C,D
我后来想到用UNION ALL的
只是查询语句长的啦
UNION ALL 和UNION 有区别吗?
select sum(total) from (
select count(*) total from dept
union all
select count(*) total from emp1
union all
select count(*) total from emp2
union all
select count(*) total from emp3)
谢谢大家
UNION ALL效率要高