更新user中parent_id为0的记录,将parent_id设置为当前用户id编号
UPDATE `user` AS u1
INNER JOIN (
SELECT id
FROM `user`
) AS u2 ON u1.id = u2.id SET u1.parent_id = u2.id
WHERE u1.parent_id = 0;
更新user中parent_id为0的记录,将parent_id设置为当前用户id编号
UPDATE `user` AS u1
INNER JOIN (
SELECT id
FROM `user`
) AS u2 ON u1.id = u2.id SET u1.parent_id = u2.id
WHERE u1.parent_id = 0;