Skip to content

Instantly share code, notes, and snippets.

@jorik041
Forked from ziadoz/restore.sql
Created June 23, 2013 05:50
Show Gist options
  • Save jorik041/5843952 to your computer and use it in GitHub Desktop.
Save jorik041/5843952 to your computer and use it in GitHub Desktop.
-- Update record revision numbers for a region, so they display in Perch.
-- Replace :regionID and :revisionNum
UPDATE perch2_content_items pci
INNER JOIN
(
SELECT
itemID,
MAX(itemRev) AS itemRevMax
FROM perch2_content_items
WHERE regionID = :regionID
GROUP BY itemID
) AS max
ON pci.itemID = max.itemID AND pci.itemRev = max.itemRevMax
SET pci.itemRev = :revisionNum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment