sql 批量修改数据

来源:百度知道 编辑:UC知道 时间:2024/07/04 08:13:35
有一张表字段A B C
A B C
1 a a
1
1
2 e 3
2
2
如果A字段的值相同,就把值相同的所有行更新为一样的,结果如下
A B C
1 a a
1 a a
1 a a
2 e 3
2 e 3
2 e 3

谢谢
SQL 2000

使用update 更新修改数据库数据,更改的结果集是多条数据则为批量修改。
语法格式如:
update 表格 set 列 = 更改值 where 筛选条件
例:
update table set a=1 --将table 中所以a列的值改为 1
update table set a=1 where b=2 --将table 中列b=2的记录中a列的值改为 1

--测试数据如下:

SQL> create table temp(a number,b varchar2(1),c varchar2(1));

Table created
SQL> insert into temp values(1,'a','a');

1 row inserted
SQL> insert into temp values(1,'','');

1 row inserted
SQL> insert into temp values(1,'','');

1 row inserted
SQL> insert into temp values(2,'e','3');

1 row inserted
SQL> insert into temp values(2,'','');

1 row inserted
SQL> insert into temp values(2,'','');

1 row inserted

SQL> select * from temp;

A B C
---------- - -
1 a a
1