gpt4 book ai didi

MySQL跨多个表计数并获得单个值

转载 作者:太空宇宙 更新时间:2023-11-03 11:04:57 25 4
gpt4 key购买 nike

想象一下: 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com