Instantly share code, notes, and snippets.

Embed
What would you like to do?
Put all Mautic Custom fields into alphabetical order by label.
UPDATE lead_fields AS f
CROSS JOIN (
SELECT @cnt := 0
) AS dummy
JOIN (
SELECT (@cnt := @cnt + 1) AS cnt, id
FROM lead_fields
CROSS JOIN (SELECT @cnt := 0) AS dummy
ORDER BY label ASC
) AS c
SET f.field_order = c.cnt
WHERE f.id = c.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment