mysql更新id字段值为连续(递增/递减)数值

实现方法:

SET @num=1; UPDATE news SET id:=@num+id ORDER BY id ASC;
首先定义num变量并赋予初始值,在执行update语句时num值+1

{{ message }}

{{ 'Comments are closed.' | trans }}