Last active
August 29, 2015 13:56
-
-
Save libo1106/8913066 to your computer and use it in GitHub Desktop.
数据库迁移,关联ID处理
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 备份关联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