MySQL中 updata的用法??

更新数据:updata

语法:

update 表名 set 字段1名字 = 字段一的值,字段2的名字=字段2的值 where 条件。

 

8.3.2更新所有数据

 

#1)将所有人的成绩 设置为100

 

update tb_user set score = 100;

 

8.3.3根据条件更新

 

#2)将学号是6的学生,成绩设为59

 

update tb_user set score = 59 where id = 5;

 

 

 

#3)将名字为cx的学生,成绩设置60

 

update tb_user set score=60 where name='cx';

 

8.3.4更新多个字段

 

#4)将学号是5的学生,成绩设为99,名字‘xx

 

update tb_user set score = 99, name = 'xx' where id = 5;

 

 

 

#5)将所有人成绩减去10

 

update tb_user set score=score-10;

 

posted on 2021-04-15 15:25  小叮同学  阅读(4169)  评论(0)    收藏  举报

导航