我想用表格列文本附加数字
Post_sortcode
post-first
post-next
post-next
输出
Post_sortcode
post-first-1
post-next-2
post-next-3
任何人帮助我......
答案 0 :(得分:1)
您需要使用动态变量来获取行号,然后使用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 强>
答案 1 :(得分:1)
你可以试试这个 -
update tbl_post set post_sortcode=concat(post_sortcode,'-',post_id)