用一句sql,查出學生名字及所有科目名和科目成績,沒有相應成績的,用'-'顯示


uj5u.com熱心網友回復:
SELECT t.name, s.`subject`, IFNULL(s.score,'-')FROM student AS t
INNER JOIN score AS s ON s.uid = t.id
uj5u.com熱心網友回復:
SELECT student.name, IFNULL(score.subject, '-') as subject, IFNULL(score.score, '-') as score FROM student LEFT JOIN score ON score.uid = student.id;轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/18280.html
標籤:MySQL
