數據按分組排序後更新排序值

 

update bg_data_column aa,(
SELECT
    @r:= case when @obj_id=a.obj_id then @r-1 else 200 end as rowNum,
    @obj_id:=a.obj_id as obj_id,
    a.id
from 
    bg_data_column a ,(select @r:=0 ,@obj_id:='') b
        where a.id <100000) bb 
        set aa.priority=bb.rowNum 
        where aa.id<100000 and aa.id=bb.id;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章