试试:
INSERT INTO `tm_setfield` ( `tsf_id` , `tsf_name` , `tsf_no` )
select NULL , '10', '10'
union all
select NULL , '11', '11'
;
INSERT INTO `tm_setfield` ( `tsf_id` , `tsf_name` , `tsf_no` )
select NULL , '10', '10'
union all
select NULL , '11', '11'
;
难道真的没有批量更新的sql语句吗?
具体想怎么更新??????
-------------------------------
批量更新某一字段的值,类似如下的sql的效果$sql1="update tm_setfield set tsf_name='1' where tsf_no='a'";
$sql2="update tm_setfield set tsf_name='2' where tsf_no='b'";
....
....
$sqln="update tm_setfield set tsf_name='n' where tsf_no='x'";
$sql1="update tm_setfield set tsf_name='str1' where tsf_no='1'";
$sql2="update tm_setfield set tsf_name='str2' where tsf_no='2'";
....
....
$sqln="update tm_setfield set tsf_name='str3' where tsf_no='3'";--------------------------------------------------------
我想用sql语句处理可能不行,我还是在程序中,用循环和数组来解决吧!
--------------------------------------------------------
crazy_boy1(小辉)
如果只是简单的加上 1,2,3,4..... 这样的行号 倒可以做到但是如果没有规律 就像 一刀 说的 做不到--------------------------------------------------------
如果是简单的行号,该怎样做呢?
想学习下!
:)
create table tab(id varchar(5) , tt varchar(5))insert into tab
select 'w','a'
union select 'r','b'
union select 'x','c'
union select 'a','d'
union select 'f','e'select * from tab
/*
id tt
-------------------
a d
f e
r b
w a
x c
*/--UPDATE
ALTER TABLE tab ADD index_c int IDENTITY(1,1)
UPDATE TAB SET id = index_c
ALTER TABLE tab DROP COLUMN index_c
select * from tab
/*
id tt
-------------------
1 d
2 e
3 b
4 a
5 c
*/--删除测试数据
drop table tab
这段代码我要好好学习下!