有人可以查看我的代码,因为我不知道MySQL中是否可以
set @max=concat('select max(length(CommentsId))from', table_name);
prepare stmt from @max;
execute stmt;
set @max=concat('UPDATE', table_name, 'SET CommentsId= ',CommentsId * power(10, (@max - length(CommentsId))),' WHERE CommentsId= ', @CommentsId );
prepare stmt from @max;
execute stmt;
答案 0 :(得分:0)
您需要在from
,UPDATE
和SET
关键字之前或之后使用空格。
set @max=concat('select max(length(CommentsId)) from ', table_name);
prepare stmt from @max;
execute stmt;
set @max=concat('UPDATE ', table_name, ' SET CommentsId= ',CommentsId * power(10, (@max - length(CommentsId))),' WHERE CommentsId= ', @CommentsId );
prepare stmt from @max;
execute stmt;