mysql 数据库,查询一个表 a ,按编号从大到小分页,一句sql 怎么写?
例如 a 表 编号1,2,3,4,5,6,7,8,9 要分3页,每页这样显示 第一页9 ,8 ,7,第二页:6,5,4,........
要全纪录的从大到小。
mysql 中分页语句怎么写
mysql 不支持 top 关键字。
例如 a 表 编号1,2,3,4,5,6,7,8,9 要分3页,每页这样显示 第一页9 ,8 ,7,第二页:6,5,4,........
要全纪录的从大到小。
mysql 中分页语句怎么写
mysql 不支持 top 关键字。
select * from a order by id desc limit 3,3; -- 第二页:6,5,4
select * from a order by id desc limit 6,3;
具体请参考手册中的select .... limit语法和例子。
MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
select * from a order by id desc limit 3,3; -- 第二页:6,5,4
select * from a order by id desc limit 6,3;赞
SELECT ... FROM ... WHERE ... ORDER BY ... FETCH FIRST n ROWS[ROW] ONLY陆续都应该支持。