我正在学习MySQL.在已创建的表中,我添加了一个列(类).现在我想在CLASS列中添加数据.要在一行中添加数据,我使用了以下代码:
update stu SET class="5th" WHERE id = 1;
个
我希望更新CLASS COLUMN中的所有行,而不是逐个更新每一行,我使用了以下命令
update stu SET
class="5th" WHERE id = 2
class="6th" WHERE id = 3
class="6th" WHERE id = 4
class="7th" WHERE id = 5
class="7th" WHERE id = 6
class="8th" WHERE id = 7
运行该命令后,显示以下错误
update stu SET class="5th" WHERE id = 2 class="6th" WHERE id = 3 class="6th" WHERE id = 4 class="7th" WHERE id = 5 class="7th" WHERE id = 6 class="8th" WHERE id = 7 Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'class="6th" WHERE id = 3 class="6th" WHERE id = 4 class="7th" WHERE id = 5 class' at line 3 0.000 sec
个
有人能告诉我如何一次更新行吗?