[转] mysql分组取每组前几条记录(排名)
参照这篇文章http://www.cnblogs.com/JulyZhang/archive/2011/02/12/1952213.html,拿出每个分类中的前几记录,写成的mysql如下:
select a.id,name,type from adpos a where 3 > (select count(*) from tablename where type = a.type and id < a.id ) order by a.type,a.id
mysql居然不会支持top ,比如select top 3 id from table order by type,id,就不行。
相关推荐
苏康申 2020-11-13
vitasfly 2020-11-12
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11