排序: asc升序 desc降序
order by 通过哪个字段排序
mysql> select a.id,a.name,subjectName,studentResult
-> from student a
-> inner join subject b
-> on a.id =b.id
-> inner join result c
-> on b.id =c.id
-> where subjectName='高等数学-1'
-> order by studentResult asc;
+----+-----------+----------------+---------------+
| id | name | subjectName | studentResult |
+----+-----------+----------------+---------------+
| 5 | 小刘 | 高等数学-1 | 45 |
| 6 | 占 | 高等数学-1 | 56 |
| 3 | 王五 | 高等数学-1 | 78 |
| 4 | 张三 | 高等数学-1 | 87 |
| 2 | 刘能 | 高等数学-1 | 89 |
| 1 | 赵六天 | 高等数学-1 | 94 |
+----+-----------+----------------+---------------+
6 rows in set (0.01 sec)
分页
mysql> select a.id,a.name,subjectName ,studentResult
-> from student a
-> inner join subject b
-> on a.id=b.id
-> inner join result c
-> on b.id =c.id
-> where subjectName = '高等数学-1'
-> order by studentResult asc
-> limit 0,5;
+----+--------+----------------+---------------+
| id | name | subjectName | studentResult |
+----+--------+----------------+---------------+
| 5 | 小刘 | 高等数学-1 | 45 |
| 6 | 占 | 高等数学-1 | 56 |
| 3 | 王五 | 高等数学-1 | 78 |
| 4 | 张三 | 高等数学-1 | 87 |
| 2 | 刘能 | 高等数学-1 | 89 |
+----+--------+----------------+---------------+
5 rows in set (0.01 sec)
mysql> select a.id,a.name,subjectName,studentResult
-> from student a
-> inner join subject b
-> on a.id = b.id
-> inner join result c
-> on b.id = c.id
-> where subjectName ='高等数学-1'
-> order by studentResult asc
-> limit 5,5;
+----+-----------+----------------+---------------+
| id | name | subjectName | studentResult |
+----+-----------+----------------+---------------+
| 1 | 赵六天 | 高等数学-1 | 94 |
+----+-----------+----------------+---------------+
1 row in set (0.01 sec)