Skip to content

Instantly share code, notes, and snippets.

@coffebar
Last active August 29, 2015 14:10
Show Gist options
  • Save coffebar/e37739ea1f12c2c7c700 to your computer and use it in GitHub Desktop.
Save coffebar/e37739ea1f12c2c7c700 to your computer and use it in GitHub Desktop.
php5shop: rename the duplicate path of categories
-- 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