MySQL增删改查中的《修改操作》

166 阅读1分钟

MySQL的修改操作

注意事项

#修改数据
update <表名> set [键]='[值]',[键]='[值]' where id=1;

修改每个值的后面一定要加上引号,否则会报错

现在进行每个单词的拆解分析

update: 后面是跟上你数据库的表名

updata cuminposts

image-20220312214339692.png

set:后面是跟上你想修改的属性值(键值对写法)

set name='cumin' // 单个写法
set name='cumin',age='19',sex='male' // 多个写法

image-20220312214616245.png

where 命令是:更新指定数据(id)

where id=13477 // 可以不加引号

b763a37121ec435fb395195885d5820c_tplv-k3u1fbpfcp-watermark.png

懂了呀,看看完整写法

update <表名> set [键]='[值]',[键]='[值]' where id=1;
对比
updata cuminposts set name='cumin',age='19',sex='male' where id=13477

网上根本找不到这么细的好嘛!是不是实话