-1

有人可以看看我的代码吗,因为我不知道它在 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;
4

1 回答 1

0

from在,UPDATESET关键字之前或之后需要空格。

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;
于 2012-08-02T13:25:51.723 回答