我有一个名为 class 的表
|Record_No [PK] | Student_No | Class_No | Seat_No |
=====================================================
|1 | 200910 | 2 | 20 |
|2 | 201234 | 2 | 13 |
|3 | 200965 | 2 | 1 |
|4 | 200920 | 2 | 8 |
|5 | 200911 | 2 | 9 |
|6 | 200955 | 1 | 10 |
|7 | 200924 | 1 | 9 |
|8 | 200922 | 1 | 1 |
|9 | 200901 | 2 | 11 |
|10 | 200902 | 2 | 18 |
是否可以按从 1 到最后一个座位号的顺序更新座位号中的数字,其中座位号的等级等于 2?
该表应如下所示:
|Record_No [PK] | Student_No | Class_No | Seat_No |
=====================================================
|1 | 200910 | 2 | 1 |
|2 | 201234 | 2 | 2 |
|3 | 200965 | 2 | 3 |
|4 | 200920 | 2 | 4 |
|5 | 200911 | 2 | 5 |
|6 | 200955 | 1 | 10 |
|7 | 200924 | 1 | 9 |
|8 | 200922 | 1 | 1 |
|9 | 200901 | 2 | 6 |
|10 | 200902 | 2 | 7 |
截至目前,我只能通过使用来实现这一点
UPDATE class SET Seat_No = 1 WHERE Class_No = 2 AND Student_No = 200910;
UPDATE class SET Seat_No = 2 WHERE Class_No = 2 AND Student_No = 201234;
...
等等..
如果不将每个 student_no 都放在查询中,我该如何解决这个问题?请帮忙。