显示查询记录的前n条 mysql limit用法
时间:2021-07-01 10:21:17
帮助过:6人阅读
select id,id_no
from torder
where user = 8 order by createtime
desc ;
+----+------------------+
| id
| id_no
|
+----+------------------+
| 12 | 2015072609100000 |
| 23 | 2015072816100000 |
| 22 | 2015072816100000 |
| 21 | 2015072816100000 |
| 20 | 2015072815100000 |
| 19 | 2015072815100000 |
| 18 | 2015072814100000 |
| 17 | 2015072810100000 |
| 16 | 2015072810100000 |
| 15 | 2015072720100000 |
| 14 | 2015072720100000 |
| 13 | 2015072609100000 |
| 10 | NULL |
| 8 | NULL |
| 7 | NULL |
| 4 | NULL |
| 9 | NULL |
| 11 | 2015072220100000 |
+----+------------------+
18 rows
in set
列出其中前5条
mysql> select id,id_no from torder where user = 8 order by createtime desc limit 5;
+----+------------------+
| id | id_no |
+----+------------------+
| 12 | 2015072609100000 |
| 23 | 2015072816100000 |
| 22 | 2015072816100000 |
| 21 | 2015072816100000 |
| 20 | 2015072815100000 |
+----+------------------+
5 rows in set
显示查询记录的前n条 mysql limit用法
标签: