Created
August 18, 2016 13:38
-
-
Save joshuabaker/2c67366f14a32718015201a41fe5cbc9 to your computer and use it in GitHub Desktop.
Appends “ (duplicate)” to any duplicate tags within a Craft CMS database. Assumes table prefix is `craft_`.
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
UPDATE craft_content | |
SET craft_content.title = CONCAT(craft_content.title, ' (duplicate)') | |
WHERE craft_content.elementId IN ( | |
SELECT tmp.elementId | |
FROM ( | |
SELECT * | |
FROM craft_content | |
) AS tmp | |
JOIN craft_tags ON craft_tags.id = tmp.elementId | |
GROUP BY tmp.title | |
HAVING COUNT(*) > 1 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs to be limited to specific tag groups via a second
JOIN
within the sub-query.