有100篇文章,我查询浏览量最高10篇文章,但是要排除100篇中最新id的10篇。
select * from table order by view limit 0,10
如何在查询结果前,先排除最新10篇,id<90这个方法不能用,有些行是被删除过的。
select * from table where view not in (select top 10 view from table order by view) order by view limit 0,10
select * from table order by view limit 0,10 offset 10
not in 这种简单的可以百度啦
select * from table where id not between (select max(id) as maxid from table)-10 and (select max(id) as maxid from table) order by view desc limit 10
select * from table where id not in (select id from table order by id desc limit 0,10) order by view desc limit 0,10
select * from table where id not in(select id from (select id from table order by view limit 0,10) t) order by view limit 0,10
试试看
总共就100 select * from table LIMIT 95,-1 order by id desc