且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更新特定的数字,该数字在mysql中大于3

更新时间:2023-02-11 17:11:51

这可能对您有所帮助.
This might help you.
declare @intflag int
declare @intstring varchar(40)
declare @intstringb4 varchar(40)
set @intflag=2
set @intstring = (select [name] from table where sno=2)
While (@intflag <=(select max(sno) from table))
begin
print @intflag
set @intstringb4 = (select [name] from table where sno=@intflag+1)
update table set [name]=@intstring where sno=@intflag+1
set @intstring = @intstringb4
set @intflag = @intflag + 1
update table set [name]='anu' where id=@intflag
end


create procedure [dbo].[updatest]
as
begin

update st set sno=sno+1 where sno>=3
insert into st values(3,'anu')
select * from st order by sno
end


您可以尝试为此编写存储过程-单个查询可能不足以完成所有操作此处理.
You could try writing a stored procedure for this - a single query may not be sufficient to do all this processing.