gpt4 book ai didi

mysql - 左连接出现 "unknown column"错误

转载 作者:行者123 更新时间:2023-11-29 12:16:26 28 4
gpt4 key购买 nike

SELECT *
FROM `placement_ans` A, `placement_quiz` B
left join `placement_time` C on (A.state=C.state)
where
A.no_place=C.no_place and A.no_stu=C.no_stu and A.no_place=B.no_place and A.place_q=B.no_q and YEAR(A.place_date) = YEAR(curdate()) and MONTH(A.place_date) = MONTH(curdate()) and A.no_place=208 and A.no_stu=793 order by A.place_q ASC

错误是“on 子句”中的未知列“A.state”

我也尝试过使用

SELECT *
FROM `placement_ans` A, `placement_quiz` B
left join `placement_time` C on (placement_ans.state=C.state)
where
A.no_place=C.no_place and A.no_stu=C.no_stu and A.no_place=B.no_place and A.place_q=B.no_q and YEAR(A.place_date) = YEAR(curdate()) and MONTH(A.place_date) = MONTH(curdate()) and A.no_place=208 and A.no_stu=793 order by A.place_q ASC

但它似乎不想工作

我有一张像这样的 table

placement_time
state num
100 10

placement_ans
state something
100 11
100 22
55 33
22 55
33 77

我想打印出一个表格

placement_ans
state something num
100 11 10
100 22 10
55 33 null
22 55 null
33 77 null

最佳答案

根据给定的示例数据集和预期结果,您不需要引用表placement_quiz,可以这样做

select a.*,b.num from placement_ans a
left join placement_time b on b.state = a.state

关于mysql - 左连接出现 "unknown column"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29722833/

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