update test5
set example@sqldat.com:=if(@grp=q_id,@srt+1,1),
example@sqldat.com:=q_id
where (0,0)=(select @grp:=0,@srt:=0)
order by q_id, `name`
Définissez le "commander par" nécessaire. La première colonne dans 'order by' doit être "q_id".
SET SQL_SAFE_UPDATES = 0;