MySQL高級之子查詢

查詢支持嵌套使用ui

查詢各學生的語文、數學、英語的成績spa

select sname,
(select sco.score from scores sco inner join subjects sub on sco.subid=sub.id where sub.stitle='語文' and stuid=stu.id) as 語文,
(select sco.score from  scores sco inner join subjects sub on sco.subid=sub.id where sub.stitle='數學' and stuid=stu.id) as 數學,
(select sco.score from  scores sco inner join subjects sub on sco.subid=sub.id where sub.stitle='英語' and stuid=stu.id) as 英語
from students stu;
相關文章
相關標籤/搜索