Last active
August 29, 2015 14:10
-
-
Save coffebar/e37739ea1f12c2c7c700 to your computer and use it in GitHub Desktop.
php5shop: rename the duplicate path of categories
This file contains 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
-- Search for duplicate path: | |
SELECT c1.id,c1.path,c2.id,c2.path FROM `p5shp_categories` as c1, `p5shp_categories` as c2 WHERE c1.id != c2.id AND c1.path=c2.path; | |
-- Fix them all | |
UPDATE `p5shp_categories` SET path = CONCAT( path, CONCAT( '_', ( | |
FLOOR( 1 + RAND( ) *60 ) )) | |
) WHERE id IN ( | |
SELECT * | |
FROM ( | |
SELECT c2.id | |
FROM `p5shp_categories` AS c1, `p5shp_categories` AS c2 | |
WHERE c1.id != c2.id | |
AND c1.path = c2.path | |
) AS x | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment