mysql 按字段a排序 并编序列号,字段a值相同的编号相同

select  a.test,b.* from (select @y:=@y+1 as test,a.* from (select * from resourcecenter.cm_identify_relation a  group by a.issue_party   ) a,(select @y:=0) d order by issue_party) a,
resourcecenter.cm_identify_relation b 
where a.issue_party=b.issue_party order by b.issue_party

先在表中创建 字段a 的分组排序 并自增序号,
然后使用原来的表 进行根据字段a赋值,并显示加的序号列

猜你喜欢

转载自www.cnblogs.com/wanderingfish/p/9394052.html
今日推荐