[英]MySQL Find records in one table that has no value of a column in another table
[英]How to show value that has column with multiple value in another table in MySQL
我需要讓他們像這樣:
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;
使用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
嘗試這個
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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.