假设有表A和表B,其中表A有10条数据,表B有15条数据,我需要查询表A+表B的总数据量,语句怎么写,这俩表完全没有关系,就是两个count(*)怎么加起来
select((select COUNT(1) from A) + (select COUNT(1) from B))
Nice
select count(*) from (select * from A Union All select * from B) S
前提是你这两个不相关的表中,字段名称是一样的,就是说如果表中有个字段name,B表中也有一个name,name就可以用这个
select count(name) from (select * from A Union All select * from B) S
两个count加起来