长标题问题,所以我为此道歉!我有两张桌子,一张如下:
Student Name Grade John Doe 96 John Foe 65 Dan Doe 76 Mary Doe 85
另一张表如下:
Grade Start Grade End Status 0 60 Bad Student 61 70 OK Student 71 80 Good Student 81 90 Great Student 91 100 Honor Student
我正在尝试创建一个可以提高学生成绩的MySQL视图,并告诉我该学生的状态如下:
Student Name Grade Status John Doe 90 Honor Student John Foe 65 OK Student
等等。我想不出一个会给我这些信息的查询。我对查询完全失去了帮助吗?
SELECT student_name, student_grade from student_grade_table WHERE ???
答案 0 :(得分:1)
使用联接:
SELECT s.student_name, s.grade, g.status
FROM students AS s
JOIN grades as g ON s.grade BETWEEN g.grade_start AND g.grade_end