sql 两个表中的总数?

来源:百度知道 编辑:UC知道 时间:2024/07/07 03:55:47
我有两个表
我想count(*)表1中的一列
同时count(*)表2中的一列
然后把这两个数家在一起 select出来
怎么做~
谢谢!!!!

select count(c.M)
from (select A.a M from tableA union select B.b M from tableB )C

//M为A.a和B.b字段的别名

select sum(c.M)
from (select A.a M from tableA union select B.b M from tableB )C
把楼上的count改成求和函数sum就没问题了

lala

select (select count(1) from 表1)+(select count(1) from 表2)

select a.cnt,b.cnt from (select count(1) as cnt from 表1) a,
(select count(1) as cnt from 表2)b