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赋值,并显示加的序号列

posted on 2018-07-31 09:07  游荡的鱼  阅读(2101)  评论(0编辑  收藏  举报

导航