MySQL 5.7 LIMIT語句介紹
LIMIT語句可以限制SELECT語句返回的行數。LIMIT使用1個或2個引數,引數必須是非負數的整數。
mysql> select * from dept2 order by 1;
+--------+-------+
| deptno | dname |
+--------+-------+
| 10 | A |
| 20 | B |
| 30 | C |
| 40 | D |
| 50 | E |
| 60 | F |
| 70 | G |
| 80 | H |
| 90 | I |
| 100 | J |
| 110 | K |
| 120 | L |
| 130 | M |
| 140 | N |
| 150 | O |
| 160 | P |
| 170 | Q |
| 180 | R |
| 190 | S |
| 200 | T |
+--------+-------+
20 rows in set (0.03 sec)
--返回第6-15行
mysql> select * from dept2 order by 1 limit 5,10;
+--------+-------+
| deptno | dname |
+--------+-------+
| 60 | F |
| 70 | G |
| 80 | H |
| 90 | I |
| 100 | J |
| 110 | K |
| 120 | L |
| 130 | M |
| 140 | N |
| 150 | O |
+--------+-------+
10 rows in set (0.00 sec)
--返回前5行
mysql> select * from dept2 order by 1 limit 5;
+--------+-------+
| deptno | dname |
+--------+-------+
| 10 | A |
| 20 | B |
| 30 | C |
| 40 | D |
| 50 | E |
+--------+-------+
5 rows in set (0.00 sec)
mysql> select * from dept2 order by 1 limit 0,5;
+--------+-------+
| deptno | dname |
+--------+-------+
| 10 | A |
| 20 | B |
| 30 | C |
| 40 | D |
| 50 | E |
+--------+-------+
5 rows in set (0.00 sec)
mysql> select * from dept2 order by 1;
+--------+-------+
| deptno | dname |
+--------+-------+
| 10 | A |
| 20 | B |
| 30 | C |
| 40 | D |
| 50 | E |
| 60 | F |
| 70 | G |
| 80 | H |
| 90 | I |
| 100 | J |
| 110 | K |
| 120 | L |
| 130 | M |
| 140 | N |
| 150 | O |
| 160 | P |
| 170 | Q |
| 180 | R |
| 190 | S |
| 200 | T |
+--------+-------+
20 rows in set (0.03 sec)
--返回第6-15行
mysql> select * from dept2 order by 1 limit 5,10;
+--------+-------+
| deptno | dname |
+--------+-------+
| 60 | F |
| 70 | G |
| 80 | H |
| 90 | I |
| 100 | J |
| 110 | K |
| 120 | L |
| 130 | M |
| 140 | N |
| 150 | O |
+--------+-------+
10 rows in set (0.00 sec)
--返回前5行
mysql> select * from dept2 order by 1 limit 5;
+--------+-------+
| deptno | dname |
+--------+-------+
| 10 | A |
| 20 | B |
| 30 | C |
| 40 | D |
| 50 | E |
+--------+-------+
5 rows in set (0.00 sec)
mysql> select * from dept2 order by 1 limit 0,5;
+--------+-------+
| deptno | dname |
+--------+-------+
| 10 | A |
| 20 | B |
| 30 | C |
| 40 | D |
| 50 | E |
+--------+-------+
5 rows in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2098147/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 5.7 PREPARE、EXECUTE、DEALLOCATE語句介紹MySql
- MySQL 5.7 的事務控制語句的介紹MySql
- mysql limit語句優化MySqlMIT優化
- MySQL 5.7 NOT EXISTS用法介紹MySql
- MySQL 5.7 Performance Schema 介紹MySqlORM
- MySQL 5.7 REPLACE語句的用法MySql
- MySQL 5.7 mysqldumpslow工具介紹MySql
- MySQL 5.5 SHOW PROFILE、SHOW PROFILES語句介紹MySql
- MySQL 5.7 EXPLAIN EXTENDED語句說明MySqlAI
- MySQL 5.5 LOCK TABLES 和 UNLOCK TABLES 語句介紹MySql
- MySQL 5.5 FLUSH TABLES WITH READ LOCK語句介紹MySql
- MySQL 5.7許可權的介紹MySql
- mongodb常用語句介紹MongoDB
- 精妙SQL語句介紹SQL
- MySQL 5.7 mysql_install_db工具介紹MySql
- MySQL 中 一條 order by index limit 語句的分析MySqlIndexMIT
- MySQL 5.7 MyISAM併發插入特性介紹MySql
- MySQL 5.7 online DDL特性介紹MySql
- MySQL5.7 JSON型別使用介紹MySqlJSON型別
- MySQL 5.7預設ONLY_FULL_GROUP_BY語義介紹以及故障解決MySql
- JavaScript return語句簡單介紹JavaScript
- javascript with()語句用法簡單介紹JavaScript
- mysql 常用sql語句 簡介MySql
- MySQL 5.7 SELECT ... LOCK IN SHARE MODE|FOR UPDATE語句說明MySql
- SQL高手篇:精妙SQL語句介紹SQL
- MySQL 5.7 使用 SELECT ... INTO 語句匯出資料檔案MySql
- 超詳細的介紹Python語句Python
- go 流程控制之switch 語句介紹Go
- javascript流程控制語句簡單介紹JavaScript
- MySQL SQL語句查詢執行過程的四個階段介紹MySql
- js如何退出迴圈語句簡單介紹JS
- MySQL 5.7 InnoDB引擎簡介MySql
- mysql語句MySql
- awk 流程控制語句(if,for,while,do)詳細介紹While
- MySQL 5.7的主要特性簡介MySql
- MySQL5.7新版本的運維,效能和新特性介紹MySql運維
- MySQL 5.7 複製控制語句SET GLOBAL sql_slave_skip_counter說明MySql
- MySql介紹MySql