Last active
November 18, 2018 21:13
-
-
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
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 `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