gpt4 book ai didi

MYSQL总计数超过1个表总结果

转载 作者:行者123 更新时间:2023-11-29 07:46:03 25 4
gpt4 key购买 nike

我有 3 张 table 。我想在 1 个结果中选择count,例如:

table1=1000 records + table2=400 records + table3=200 records = 1600  

1600 是我想要从服务器返回的一个结果。

也许是 MySQL 内连接?有什么建议吗?

最佳答案

试试这个:

select sum(c) from (
select count(*) as c from table1
union
select count(*) as c from table2
union
select count(*) as c from table3
) tmp

这将为您提供总数。

关于MYSQL总计数超过1个表总结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27777541/

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