假设student的主键字段是id
select d.* from( select substring_index(group_concat(a.id order by a.height desc,a.id asc),',',1) as id from student as a inner join class as b on a.class_id=b.id group by a.class_id)as c inner join student as d on c.id=d.id
上面的语句当出现身高相同时,按主键id来升序排序,如果想要身高相同的按主键id降序那就是a.id asc改成 a.id desc
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)