gpt4 book ai didi

mysql - 将左连接与逗号组合起来

转载 作者:行者123 更新时间:2023-11-29 17:36:26 25 4
gpt4 key购买 nike

所以我得到了这个 SQL 代码:

SELECT * 
FROM A a1, AP ap1, P p1, M m1
LEFT JOIN F f1 ON f1.id_f = p1.f1
LEFT JOIN C c1 ON p1.c_id = c1.c_id
LEFT JOIN S s1 on p1.saison_id = s1.s_id
WHERE a1.a_type NOT IN (1)
AND a1.type_c IN (1,2)
AND ap1.a_id = a1.achats_id
AND p1.p_id = ap1.products_id
AND p1.m_id = m1.m_id
ORDER BY a_id ASC

我收到此错误:

#1054 - Unknown column 'p1.f1' in 'on clause' 

所以我不知道为什么它不能识别第 3 行的 p1.f1。有什么想法吗?

最佳答案

您只需使用正确的 JOININNER JOIN 语法即可:

SELECT * 
FROM A a1 JOIN
AP ap1
ON ap1.a_id = a1.achats_id JOIN
P p1
ON p1.p_id = ap1.products_id JOIN
M m1
ON p1.m_id = m1.m_id LEFT JOIN
F f1
ON f1.id_f = p1.f1 LEFT JOIN
C c1
ON p1.c_id = c1.c_id LEFT JOIN
S s1
ON p1.saison_id = s1.s_id
WHERE a1.a_type NOT IN (1) AND a1.type_c IN (1, 2)
ORDER BY a1.a_id ASC;

瞧!问题解决了。

关于mysql - 将左连接与逗号组合起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50251365/

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