我需要证明他们是这样的:
performance_id | quiz_id
________________________
22 | 65
23 | null
24 | 43
25 | null
我尝试加入,但显示错误的结果。它不显示测验ID。我试过这个:
SELECT A.performance_id, C.quiz_id
FROM A
LEFT JOIN B ON A.performance_id=B.performance_id
LEFT JOIN C ON B.phc_id = C.phc_id
group BY A.performance_id;
答案 0 :(得分:1)
使用group_concat
:
SELECT A.performance_id, group_concat(C.quiz_id)
FROM A
LEFT JOIN B ON A.performance_id=B.performance_id
LEFT JOIN C ON B.phc_id = C.phc_id
group BY A.performance_id;
因为您获得了多个quiz_id
答案 1 :(得分:0)
试试这个
SELECT A.performance_id, group_concat(C.quiz_id)
FROM A
LEFT JOIN B ON A.performance_id = B.performance_id
LEFT JOIN C ON B.phc_id = C.phc_id
group BY A.performance_id;