gpt4 book ai didi

mysql - INNER, OUTER OR RIGHT JOIN with 3 tables where one has same PK as the joining one 但 1st doesn't

转载 作者:行者123 更新时间:2023-11-28 23:30:05 25 4
gpt4 key购买 nike

您好,我目前正在尝试合并 3 种类型的表格。我必须用具有相同值的 2 来做这件事,但是当您想要第三张表与第二张表具有相同的 pk 但不是第一张表时会发生什么?我撞到了一堵巨大的砖墙……我该如何解决这个问题?

SELECT xxx.orderid, xxx.ordertime,xxx2.produdct, xxx2.product type, xxx3.priscut xx3.pricename FROM xxx
INNER JOIN xxx2 ON xxx.orderid= xxx2.orderid
RIGHT JOIN xxx3 ON xxx2.productid = xx3.productid;

我最良好的祝愿,迈克

最佳答案

简单的使用内连接

SELECT 
xxx.orderid
, xxx.ordertime
,xxx2.produdct
, xxx2.producttype
, xxx3.priscut xx3.pricename
FROM xxx
INNER JOIN xxx2 ON xxx.orderid= xxx2.orderid
INNER JOIN xxx3 ON xxx2.productid = xx3.productid;

关于mysql - INNER, OUTER OR RIGHT JOIN with 3 tables where one has same PK as the joining one 但 1st doesn't,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37633082/

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