我是初学者,我想: - 当 total quant = 0 且第二个表中的 status 字段等于 process 时,从下表中获取 recivedID table 1 - stockTBL
这意味着当此订单中的所有产品 = 0 且订单状态 = 处理时 我想返回 recivedID
这是我的代码:
SELECT s.recivedID FROM stockTBL s
JOIN recivedTBL r ON r.recivedID = s.recivedID
WHERE r.status = @STATUS
GROUP BY s.recivedID
HAVING (SUM(s.quant) = 0)
最佳答案
因此,您想要选择所有已接收的 TBL 记录,这些记录没有关联的库存 TBL。
SELECT s.recivedID, SUM(s.quant)
FROM stockTBL s
JOIN recivedTBL r ON r.recivedID = s.recivedID
WHERE r.status = @STATUS
GROUP BY s.recivedID
HAVING (SUM(s.quant) = 0) -- sum stockTBL
关于c# - 如何从另一个表中的另一列等于我的参数值的表中选择数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41491526/