2025年SQL --更新语句

SQL --更新语句目录 1 更新数据 update 1 1 使用过滤条件进行更新 1 2 更新整列数据 1 更新数据 update 语法 update 表名 set 字段 1 xxx 字段 n xxx where 条件表达式 1 1 使用过滤条件进行更新

大家好,我是讯享网,很高兴认识大家。

目录

1, 更新数据(update)

1-1, 使用过滤条件进行更新

1-2, 更新整列数据


讯享网


1, 更新数据(update)

语法:update 表名 set 字段1='xxx', ..., 字段n='xxx' where 条件表达式;

1-1, 使用过滤条件进行更新

mysql> update dept set dname = 'fdsf', loc = 'fdsaf' where deptno >= 50 and deptno <= 70; Query OK, 3 rows affected (0.17 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> select * from dept; +--------+------------+----------+ | deptno | dname | loc | +--------+------------+----------+ | 10 | ACCOUNTING | NEW YORK | | 20 | RESEARCH | DALLAS | | 30 | SALES | CHICAGO | | 40 | OPERATIONS | BOSTON | | 50 | fdsf | fdsaf | | 60 | fdsf | fdsaf | | 70 | fdsf | fdsaf | +--------+------------+----------+ 7 rows in set (0.00 sec)

讯享网

1-2, 更新整列数据

语法:update 表名 set 字段1='xxx', ..., 字段n='nnn';

讯享网mysql> update dept_copy set dname='aaa', loc='bbb'; Query OK, 7 rows affected (0.10 sec) Rows matched: 8 Changed: 7 Warnings: 0 mysql> select * from dept_copy; +--------+-------+------+ | deptno | dname | loc | +--------+-------+------+ | 10 | aaa | bbb | | 20 | aaa | bbb | | 30 | aaa | bbb | | 40 | aaa | bbb | | 50 | aaa | bbb | | 60 | aaa | bbb | | 70 | aaa | bbb | | 80 | aaa | bbb | +--------+-------+------+ 8 rows in set (0.00 sec)

小讯
上一篇 2025-01-15 21:21
下一篇 2025-03-11 18:13

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/61423.html