8战魂5无双8的gravatar头像
8战魂5无双8 2020-05-28 11:17:12
mysql统计查询大坑

你两个count 没有分组 肯定只能是一条,而union会去重,所2113以两数据一样的时候就只有一5261条了

如果你要求两4102表数据总量的话可以这样
select sum(cnt) from (
select count(*) as cnt from 表1
union all
select count(*) as cnt from 表2


要用1653union all 要不数据会不准确哦
你试下


打赏
最近浏览
opq221  LV3 2023年3月22日
最代码-宋家辉  LV61 2022年8月2日
水光浮藻  LV6 2022年8月2日
youwuzuichen  LV10 2022年6月6日
slavewen  LV2 2021年10月9日
小于一直在  LV1 2021年7月1日
zhangming12zhang 2021年4月17日
暂无贡献等级
rya123  LV1 2021年3月2日
huangyangcheng  LV4 2021年1月22日
dingjiaqiang  LV5 2020年10月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友