我想在表格列文本中附加数字
Post_sortcode
post-first
post-next
post-next
输出
Post_sortcode
post-first-1
post-next-2
post-next-3
谁能帮帮我...
最佳答案
您需要使用动态变量来获取行号,然后使用 join 进行更新
update Post_sortcode t join
(
select
t1.post_id,
@r := @r+1 as rr
from Post_sortcode t1,(select @r:=0)r
)u on u.post_id = t.post_id
set t.post = concat(t.post,'-',u.rr);
<强> DEMO
关于mysql - 更新列并附加数字和列文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28672743/