Skip to content

Instantly share code, notes, and snippets.

@libo1106
Last active August 29, 2015 13:56
Show Gist options
  • Save libo1106/8913066 to your computer and use it in GitHub Desktop.
Save libo1106/8913066 to your computer and use it in GitHub Desktop.
数据库迁移,关联ID处理
# 备份关联id
UPDATE `cats` SET temp_cat_id = cat_id
# 动态更新新关联id
UPDATE cats parent,cats child
SET child.parent_cat_id = parent.cat_id
WHERE child.parent_cat_id = parent.temp_cat_id
AND child.parent_cat_id <> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment