The groups need to be ordered when multiple groups are in each survey. It can also be used to number them across languages for each group in the #_groups table which is what is sought to be done here (# is the table prefix without the underscore separator).
-- Reorder group_order in #_groups table
UPDATE `#_groups` d LEFT JOIN (
SELECT a.gid, a.sid, a.group_order, `language`, @a:=IF(@b <> a.gid, 1, (@a+1)) AS new_order, @b:=a.gid
FROM `#_groups` a, (SELECT @a:=0, @b:=0) b ORDER BY gid
) c USING (gid, `language`) SET d.group_order=c.new_order;
The groups need to be ordered when multiple groups are in each survey. It can also be used to number them across
language
s for eachgroup
in the#_groups
table which is what is sought to be done here (#
is the table prefix without the underscore separator).