gpt4 book ai didi

mysql - 使用左外连接时,第二个表中的数据会重复

转载 作者:行者123 更新时间:2023-11-29 20:49:35 25 4
gpt4 key购买 nike

大家早上好。我正在创建一个 MySQL 命令进行此输出。

enter image description here

但是当我尝试时,输出是这样的。

enter image description here

这是我的代码。

select purchorder.PONo,purchorder.ItemCode,purchorder.Description,
purchorder.OrderQty,
receiving.ItemCode,receiving.Description,Receiving.ReceivedQty from purchorder
LEFT OUTER JOIN Receiving on receiving.RIno = purchorder.RINumber where
purchorder.PONo = 'P0239ROI'
Group BY purchorder.ItemCode;

表格采购订单

enter image description here

表接收

enter image description here

如何实现上面的输出? (带有黄色标题)

这是最新可能的答案

enter image description hereTYSM

最佳答案

您只需删除 group by 子句并在 SELECT 子句中添加 receiving.RIno 即可实现此目的。

SELECT DISTINCT
purchorder.PONo,
purchorder.ItemCode,
purchorder.Description,
purchorder.OrderQty,
receiving.RIno,
receiving.ItemCode,
receiving.Description,
Receiving.ReceivedQty
FROM purchorder
LEFT JOIN Receiving ON receiving.RIno = purchorder.RINumber
AND Receiving.ItemCode = purchorder.ItemCode
WHERE purchorder.PONo = 'P0239ROI'

关于mysql - 使用左外连接时,第二个表中的数据会重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38176275/

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