欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mysql 成长之路(五)利用LIMIT限制输出结果

程序员文章站 2024-02-19 12:40:40
...

原数据

mysql> select * from simple_account;
+----+-----------+-------+-----+---------+
| id | name      | sex   | age | money   |
+----+-----------+-------+-----+---------+
|  1 | Tom       | man   |  20 | 4539.02 |
|  2 | Jack      | man   |  19 | 2109.50 |
|  3 | 原氏      | man   |  17 |  666.66 |
|  4 | 半藏      | man   |  22 | 1666.66 |
|  5 | 天使      | woman |  23 | 9700.00 |
|  6 | 莫伊拉    | woman |  30 | 5980.02 |
|  7 | 张三      | man   |  20 | 1000.00 |
|  8 | 张四      | woman |  21 | 2000.00 |
|  9 | 李明      | man   |  20 | 1500.00 |
| 10 | Jenny     | woman |  21 | 1200.00 |
+----+-----------+-------+-----+---------+
10 rows in set (0.00 sec)

limit n形式

显示前3行

mysql> select * from simple_account limit 3;
+----+--------+-----+-----+---------+
| id | name   | sex | age | money   |
+----+--------+-----+-----+---------+
|  1 | Tom    | man |  20 | 4539.02 |
|  2 | Jack   | man |  19 | 2109.50 |
|  3 | 原氏   | man |  17 |  666.66 |
+----+--------+-----+-----+---------+
3 rows in set (0.00 sec)

limit m, n形式

显示第二行开始的两行

mysql> select * from simple_account limit 2, 2;
+----+--------+-----+-----+---------+
| id | name   | sex | age | money   |
+----+--------+-----+-----+---------+
|  3 | 原氏   | man |  17 |  666.66 |
|  4 | 半藏   | man |  22 | 1666.66 |
+----+--------+-----+-----+---------+
2 rows in set (0.00 sec)
相关标签: Mysql limit limit