DML语言中 update使用
update 修改谁 (条件) set原来的值=新值
--修改学员名字,带了简介
update `student` set `name`='宏达' where id=1
--不指定条件下的情况,会改动所有的表
update `student` set `name`='长江七号'
--修改多个属性,用逗号隔开
update `student` set `name`='宏达' where id=1
--语法
--update 表名 set conlnum_name = value,[conlnum_name = value...] where [条件]
条件:where子句 运算符 id等于某个值 ,大于某个值,在某个区间内修改…
操作符会返回布尔值
通过多个条件定位数据
操作符 | 含义 | 范围 | 结果 |
---|---|---|---|
= | 等于 | 5=6 | false |
<>或!= | 不等于 | 5<>6 | true |
< | |||
> | |||
<= | |||
>= | |||
between…and… | 在某个区间内 | [2,5] | |
and | 和 | 5>1and1>2 | false |
or | 或 | 5>1or1>2 | true |
语法:update 表名 set conlnum_name = value,[conlnum_name = value...] where [条件]
注意事项:
-
conlnum_name 是数据库的列,尽量带上``
-
条件,筛选的条件,如果没有指定,则会修改所有的列
-
value,是一个具体的值,也可以是一个变量
-
多个设置的属性之间,使用英文逗号个烤
update `student` set `birthday`=current_time where `name`='长江七号' and sex='女'