SQL insert问题

来源:百度知道 编辑:UC知道 时间:2024/09/22 04:24:53
如何实现把一个表里所有[名字]=@oldname的记录再insert到这个表里,并且把[名字]改成@newname。

insert into table(theName,field1,field2,……)
select '@newname',field1,field2,……
from table
where theName=@oldname

field1,field2 代表你的table中的除名字以外的其他列

insert new_table(名字,...--其它列)
select [名字]=@newname,...--其它列
from table
where [名字]=@oldname