表格式为
id username create
1 zh 2
2 zs 2
3 ts 1
4 gg 3
我想把create中的值换成对应的username
id username create
1 zh zs
2 zs zs
3 ts zh
4 gg ts
这是结果
------解决方案--------------------
select a.id,a.username,b.username as create from table as a inner join table as b on a.id=b.create
update a set username =b.username from table as a inner join table as b on a.id=b.create
------解决方案--------------------
update a set a.create =b.username
from mytable a , mytable b
where a.create = b.id