declare c int
set c = 1
while c<700 do
update users set profile_display_name = concat(substring(first_name,1,1), last_name)
where profile_display_name is null and id between ((c-1)*10000+1) and (c*10000);
SET c = c+1;
End while ;
Run Code Online (Sandbox Code Playgroud)
我收到错误。接近声明和结束 while 语句。我哪里出错了??
这对我来说效果更好
DELIMITER $$
CREATE DEFINER=`ops`@`localhost` PROCEDURE `myproc`()
BEGIN
DECLARE c INT;
SET c = 1;
WHILE c < 700 DO
SELECT CONCAT('Loop #:', c) ;
update users
set profile_display_name = concat(substring(first_name,1,1), last_name)
where (profile_display_name is null or profile_display_name = '')
and id between ((c-1)*10000+1) and (c*10000);
commit;
SET c=c+1;
END WHILE;
END
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42608 次 |
| 最近记录: |