相信我,天才无法与我媲美

MySQL 设置数据按条件查询下的序号

2017-11-13

ALTER TABLE mytable ADD forder INT DEFAULT 0;

UPDATE mytable r,(
    SELECT a.fid,(@rownum:=@rownum+1) AS forder
    FROM mytable a,(SELECT @rownum:=0) b
    ORDER BY ftype ASC,fnum ASC
) t
SET r.forder=t.forder
WHERE r.fid =t.fid

https://www.cnblogs.com/yjl49/archive/2012/08/21/2649582.html

作者:lrxin | Categories:未分类 | Tags:

发表评论