select a.*
from
(
select t1.*,(select count(*)+1 from 表 where 分组字段=t1.分组字段 and 排序字段<t1.排序字段) as group_id
from 表 t1
) a
where a.group_id<=3
Try this one,should be fine下面这个已经有排序了哦,不行么? SELECT uid, group_concat(subject)FROM (SELECT id, uid, subject FROM (SELECT id, uid, subject, (SELECT COUNT(*) FROM t_subject WHERE uid = t.uid AND subject <= t.subject) RKFROM t_subject t) t1WHERE rk <= 3) t2 GROUP BY uid 多了个a.原来或者你直接用个substring()得了。。。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)