如表aid title1 a
2 b
4 c
5 d
6 f
7 g 我要查询出倒数第五个id怎么写sql语句上面表查询结果是
id
2请问怎么查询谢谢
2 b
4 c
5 d
6 f
7 g 我要查询出倒数第五个id怎么写sql语句上面表查询结果是
id
2请问怎么查询谢谢
解决方案 »
- 求助,mysql存储过程
- mysql实现多个字段重复内容的查询
- MySQL在多个索引的情况下的默认排序规则是什么?能否指定默认排序索引?
- 为MYsql添加表、列注释
- MYSQL安装服务失败,怎么办?
- sql 语句 大师帮帮 小弟!
- blob字段上传和下载大小不一样!!!
- mysql 奇怪的问题。查询以 孙 开头的字段,连 任,宋 都能查出来 .为什么?
- 为什么我在Mysql 中插入一条数据,然后紧接着select刚插入的记录的ID号,怎么select 出来是一个空值???
- 在Windows环境下管理mysql最好的软件是什么?
- MySQL管理员宝典 (Wiley 2009年5月最新版)
- you have an error in your sql syntax;check the manual
from a
order by id desc
limit 4,1
id int,
title varchar(5)
);insert into a values(1,'a');
insert into a values(2,'b');
insert into a values(4,'c');
insert into a values(5,'d');
insert into a values(6,'f');
insert into a values(7,'g');
/**查询**/
select id
from a
order by id desc
limit 4,1/**
id
------
2
**/
意思就是查询第五条
+--------+-----------+
| userid | username |
+--------+-----------+
| 2 | 螟ァ譏ッ荳ェ |
| 3 | 譏ッ蠕キ蝗ス |
| 4 | |
| 5 | 莠懶ス難ス・ |
| 6 | 螢ォ螟ァ螟ォ |
| 7 | d |
| 8 | 螳俶婿 |
| 9 | ? |
+--------+-----------+
8 rows in set (0.00 sec)
mysql> select * from user limit 4,1;
+--------+-----------+
| userid | username |
+--------+-----------+
| 6 | 螢ォ螟ァ螟ォ |
+--------+-----------+
1 row in set (0.00 sec)
limit 有两个参数 第一个是起始位置,第二个是记录条数
+--------+-----------+
| userid | username |
+--------+-----------+
| 2 | 螟ァ譏ッ荳ェ |
| 3 | 譏ッ蠕キ蝗ス |
+--------+-----------+
2 rows in set (0.00 sec)默认是从0开始
即limit 2等价于limit 0,2