最近遇到一個關於mysql的查詢的問題,就是在成績表里查詢各科成績都在80以上(含80分)的學生姓名,在網上找了一個例子,供大家參考學習:
1、

2、也有人在網上用了別外的辦法來查找,如下:
使用了分組group by,
SELECT D.name FROM (
SELECT S.name,S.score AS ITEM1,S1.score AS ITEM2,S2.score AS ITEM3
FROM Student S
inner join Student S1 on S.name = S1.name and S.course <> S1.course
inner join Student S2 on S.name = S2.name and S.course <> S2.course
WHERE S.score>=80 and S1.score>=80 and S2.score>=80
) D
GROUP BY D.name
