Skip to content

Instantly share code, notes, and snippets.

@sylwit
Last active November 18, 2018 21:13
Show Gist options
  • Save sylwit/5072154 to your computer and use it in GitHub Desktop.
Save sylwit/5072154 to your computer and use it in GitHub Desktop.
Improve prestashop SQL query in Feature::cleanPositions() Do all the job in a single query
UPDATE `ps_feature` f LEFT JOIN
(SELECT @i := @i +1 AS rank, id_feature, position, test
FROM `ps_feature` JOIN (SELECT @i := 0) dummy
ORDER by position) AS f2
USING(id_feature)
SET f.position = f2.rank-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment