数据库
首页 > 数据库> > mysql 按组内顺序 分配序号

mysql 按组内顺序 分配序号

作者:互联网

UPDATE pay_method_basic_info ft INNER JOIN ( SELECT channel_id, method_id, IF ( @channelId = t.channel_id, @row_num := @row_num + 1, @row_num := 1 ) AS row_num, @channelId := t.channel_id FROM pay_method_basic_info t ) mt ON ft.channel_id = mt.channel_id AND ft.method_id = mt.method_id SET ft.method_id = ft.channel_id * 100 + row_num

标签:ft,组内,id,num,mysql,序号,method,channel,row
来源: https://www.cnblogs.com/Asuphy/p/14332393.html