这应该工作
update content,( select @row_number:=ifnull(@row_number, 0)+1 as new_position, ContentID from content where CategoryID=1 order by position) as table_positionset position=table_position.new_positionwhere table_position.ContentID=content.ContentID;
但我更喜欢先应用此方法,以取消设置用户定义的变量
由Mchl添加:set @row_number:=0;
update content,( select @row_number:=ifnull(@row_number, 0)+1 as new_position, ContentID from content where CategoryID=1 order by position) as table_position,( select @row_number:=0) as rowNumberInitset position=table_position.new_positionwhere table_position.ContentID=content.ContentID;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)