转载 https://blog.csdn.net/jslcylcy/article/details/72627762
score表:
CREATE TABLE `score` (
`student_id` int(10) DEFAULT NULL,
`class_id` int(10) DEFAULT NULL,
`score` int(5) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
1
2
3
4
5
字段 student_id 学生 id ,class_id:班级 id ,score:分数
数据准备:
insert into score values(1,1,100),(2,1,93),(3,1,89),(4,1,96),(5,2,98),(6,2,97),(7,2,90),(8,2,88),(9,1,96);
表结构如下:
mysql> select * from score;
+------------+----------+-------+
| student_id | class_id | score |
+------------+----------+-------+
| 1 | 1 | 100 |
| 2 | 1 | 93 |
| 3 | 1 | 89 |
| 4 | 1 | 96 |
| 5 | 2 | 98 |
| 6 | 2 | 97 |
|