当前位置:网站首页>【左连接】坑点
【左连接】坑点
2022-07-29 14:23:00 【陈晓明start】
SELECT
a.*,
count(c.warehouse_id) stockNum
from
warehouse111 a
LEFT JOIN user b ON a.admin_id=b.user_id
LEFT JOIN stock c ON a.id=c.warehouse_id
where a.enable_flag=0 and c.enable_flag=0
group by
a.id
上面的SQL有问题,左连接变成和内连接一样了,必须跟下面的一样
SELECT
a.*,
count(c.warehouse_id) stockNum
from
warehouse111 a
LEFT JOIN user b ON a.admin_id=b.user_id
LEFT JOIN stock c ON a.id=c.warehouse_id and c.enable_flag=0
where a.enable_flag=0
group by
a.id
边栏推荐
猜你喜欢

The reason for Apple's official price reduction has been found, and it is also facing declining sales and even inventory problems

C#实现线程管理类

蚂蚁三面滑铁卢!遭分布式截胡,靠这些笔记潜修30天,挺进京东

2022年了!还在用定时器实现动画?赶紧试试requestAnimationFrame吧!

The new technical director, who is in the form of a isXxx Boolean type definition, tomorrow need not come!

480-82(59、151)

【Postman】Download and installation (novice graphic tutorial)

如何返回一个数字的所有质因数?

How to return all prime factors of a number?

Offensive EA&UML day arch - activity diagram: : Variable Actions (continue)
随机推荐
FPGA刷题——跨时钟域传输(FIFO+打拍+握手)
没遇到过这三个问题都不好意思说用过Redis
kubernetes中正strace etcd
这 6 款在线 PDF 转换工具,得试试
AQS源码阅读与强软弱虚4种引用以及ThreadLocal原理与源码
Violence recursion to dynamic programming 02 (very clever game of CARDS)
兆骑科创海外高层次人才引进平台,企业项目对接,赛事活动路演
这么多年了,还搞不懂正则语法?
电视处理器a53和a55哪个厉害(cortexa55处理器好吗)
【pytorch】1.6 tensor 基本运算
测试时间的评估:开发时间的1/3~1/2
C#实现线程管理类
480-82(59、151)
Bika LIMS 开源LIMS集—— SENAITE的使用(分析/测试、方法)
AVH部署实践 (一) | 在Arm虚拟硬件上部署飞桨模型
城市污水处理过程模型预测控制研究综述
PytestFixture实战应用+Pytest.ini与conftest.py应用详解+Fixture及yield实现用例前置后置
The reason for Apple's official price reduction has been found, and it is also facing declining sales and even inventory problems
升级openssl1.1.1(mix2s哪个版本不断流)
暴力递归到动态规划 02 (绝顶聪明的人的纸牌游戏)