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 clause'
中的未知列'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
但它似乎不想工作
我有一张像
这样的表格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
答案 0 :(得分:1)
从给定的示例数据集和预期结果中,您不需要引用表placement_quiz
,它可以作为
select a.*,b.num from placement_ans a
left join placement_time b on b.state = a.state
答案 1 :(得分:0)
尝试将左连接序列设置如下:
SELECT *
FROM placement_ans A
left join placement_time C on (A.state=C.state),
placement_quiz B
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