更新数据

语法:

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

 

1更新所有数据

 

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

 

update tb_user set score = 100;

 

 

 

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

 

update tb_user set score = score * 0.7;

 

update tb_user set score = score - 10;

 

2根据条件更新

 

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

 

update tb_user set score = 59 where id = 6;

 

 

 

#(3)将名字为ww的学生,成绩设为60;

 

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

 

3更新多个字段

 

#(4)将学号是5的学生,成绩设为99,名字'xl';3

 

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

 

posted @ 2021-04-17 20:02  诺果  阅读(81)  评论(0)    收藏  举报