想象一下: t1 = 1 t2 = 3 t3 = 5
我需要在每个表上运行单独的选择,并以单个数量报告计数,即:
select *
from (select count(*) from t1)
+ (select count(*) from t2)
+ (select count(*) from t3);
我的最终结果应该是 = 9
最佳答案
你很接近;你可以这样写:
select (select count(*) from t1)
+ (select count(*) from t2)
+ (select count(*) from t3)
;
关于MySQL跨多个表计数并获得单个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12516078/