如表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请问怎么查询谢谢
解决方案 »
- php+mysql 正在后台处理时刷新网页,会中断处理吗?
- mysql数据查询问题,类似行转列,望各位帮忙解答
- left join 不起作用,高手帮忙看下
- 我的WEB程序访问MYSQL是不要密码的,可是MYSQL有密码?
- 关于存储过程返回日期型的问题。
- 网站死锁错误
- 关于主从服务器同步的问题
- win98安装mysql的问题
- 怎么使用在mysql中使用变量,使用触发器!
- 【mysql8.0问题】创建数据库提示parsing DDL错误
- 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