gpt4 book ai didi

mysql - 1054 - 'XXX' 中的未知列 'on clause'

转载 作者:行者123 更新时间:2023-11-29 01:09:07 25 4
gpt4 key购买 nike

下面的 SQL 语句在几年前可以工作,现在不行了,我得到这个错误信息:

1054 - Unknown column 'Promotion_Card_details.Card_id' in 'on clause'

这是我的 SQL 语句:

SELECT DISTINCT Promotion_Card_details.Card_id, 
Promotion_Merchant_details.Merchant_id,
Promotion_details.Promotion_id,
Issuer_details.IssuerName,
Card_details.CCType,
PaymentType_details.PaymentTypeName,
Merchant_details.MerchantName,
PromotionText,
PromotionEndDate
FROM Promotion_details
INNER JOIN Card_details ON (Card_details.Card_id=Promotion_Card_details.Card_id)
INNER JOIN Issuer_details ON (Issuer_details.Issuer_id=Card_details.Issuer_id)
INNER JOIN PaymentType_details ON (PaymentType_details.PaymentType_id=Card_details.PaymentType_id)
INNER JOIN Merchant_details ON (Merchant_details.Merchant_id=Promotion_Merchant_details.Merchant_id)
INNER JOIN Promotion_Merchant_details ON (Promotion_Merchant_details.Promotion_id=Promotion_details.Promotion_id)
INNER JOIN Promotion_Card_details ON (Promotion_details.Promotion_id=Promotion_Card_details.Promotion_id)
WHERE ((Promotion_details.Promotion_id = '13' OR Promotion_details.Promotion_id = '14'
OR
Promotion_details.Promotion_id = '15' OR Promotion_details.Promotion_id = '16' OR
Promotion_details.Promotion_id = '17' OR Promotion_details.Promotion_id = '18' OR
Promotion_details.Promotion_id = '19' OR Promotion_details.Promotion_id = '20' OR
Promotion_details.Promotion_id = '21' OR Promotion_details.Promotion_id = '22' OR
Promotion_details.Promotion_id = '23' OR Promotion_details.Promotion_id = '24' OR
Promotion_details.Promotion_id = '25' OR Promotion_details.Promotion_id = '361'
OR Promotion_details.Promotion_id = '364' OR Promotion_details.Promotion_id = '382') )

任何帮助将不胜感激,因为我已经在某些部分尝试了括号,但它仍然没有修复它。

最佳答案

JOIN 是左关联的,因此给定的 ON 子句只能引用已经提到的表。所以,重新排序这些:

FROM Promotion_details 
INNER JOIN Card_details ON (Card_details.Card_id=Promotion_Card_details.Card_id)
INNER JOIN Issuer_details ON (Issuer_details.Issuer_id=Card_details.Issuer_id)
INNER JOIN PaymentType_details ON (PaymentType_details.PaymentType_id=Card_details.PaymentType_id)
INNER JOIN Merchant_details ON (Merchant_details.Merchant_id=Promotion_Merchant_details.Merchant_id)
INNER JOIN Promotion_Merchant_details ON (Promotion_Merchant_details.Promotion_id=Promotion_details.Promotion_id)
INNER JOIN Promotion_Card_details ON (Promotion_details.Promotion_id=Promotion_Card_details.Promotion_id)

进入这个顺序:

FROM Promotion_details 
INNER JOIN Promotion_Card_details ON (Promotion_details.Promotion_id=Promotion_Card_details.Promotion_id)
INNER JOIN Card_details ON (Card_details.Card_id=Promotion_Card_details.Card_id)
INNER JOIN Issuer_details ON (Issuer_details.Issuer_id=Card_details.Issuer_id)
INNER JOIN PaymentType_details ON (PaymentType_details.PaymentType_id=Card_details.PaymentType_id)
INNER JOIN Promotion_Merchant_details ON (Promotion_Merchant_details.Promotion_id=Promotion_details.Promotion_id)
INNER JOIN Merchant_details ON (Merchant_details.Merchant_id=Promotion_Merchant_details.Merchant_id)

关于mysql - 1054 - 'XXX' 中的未知列 'on clause',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9230534/

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