-- Uses "abcd_" as the table prefix
-- set @a:=0; -- q_o
-- SET @b:=0; -- sid
-- SET @c:=0; -- qid
UPDATE `abcd_questions` a LEFT JOIN (
SELECT qid, sid, title, question_order, new_order FROM (
SELECT qid, sid, title, question_order, @a:=IF(@b <> sid, 1, IF(@c<>qid, @a+1, @a)) AS new_order, @b:=sid, @c:=qid
FROM `abcd_questions`, (SELECT @a:=0, @b:=0, @c:=0) b
ORDER BY sid, title
) c GROUP BY qid
) d USING (qid) SET a.question_order = d.new_order;
Across languages, the question_order should be same and the field is in the abcd_questions table. This order is now on a per language basis as different types of questions may need to be arranged according to the language used. The above re-numbering is usefull if the base language question_order is needed to be the same across all languages.
Across languages, the
question_order
should be same and the field is in theabcd_questions
table. This order is now on a per language basis as different types of questions may need to be arranged according to the language used. The above re-numbering is usefull if the base language question_order is needed to be the same across all languages.