MySQL/LIMIT:修订间差异
来自康健生活
创建页面,内容为“== 引言 == 查询第一条数据。 {{Shc_out|<syntaxhighlight lang="mysql"> SELECT * FROM kangkk LIMIT 1;</syntaxhighlight>|<syntaxhighlight lang="bash"> SELECT *…” |
|||
| 第1行: | 第1行: | ||
== 引言 == | == 引言 == | ||
== 查询 == | |||
数据样本。 | |||
{{Shc_out|<syntaxhighlight lang="mysql"> | |||
SELECT * FROM user;</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
+----+----------+---------------------+ | |||
| id | name | email | | |||
+----+----------+---------------------+ | |||
| 1 | kangjian | kangjian@kangkk.com | | |||
| 2 | kangkk | kangkk@kangkk.com | | |||
| 3 | 365 | 365@kangkk.com | | |||
| 4 | test | test@kangkk.com | | |||
+----+----------+---------------------+ | |||
4 rows in set (0.00 sec) | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
查询第一条数据。 | 查询第一条数据。 | ||
{{Shc_out|<syntaxhighlight lang="mysql"> | {{Shc_out|<syntaxhighlight lang="mysql"> | ||
SELECT * FROM | SELECT * FROM user LIMIT 1;</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
+----+----------+---------------------+ | |||
</syntaxhighlight>| | | id | name | email | | ||
+----+----------+---------------------+ | |||
| 1 | kangjian | kangjian@kangkk.com | | |||
+----+----------+---------------------+ | |||
1 row in set (0.00 sec) | |||
</syntaxhighlight>|mysql>}} | |||
查询前第二条到第四条数据。 | |||
{{Shc_out|<syntaxhighlight lang="mysql"> | {{Shc_out|<syntaxhighlight lang="mysql"> | ||
SELECT * FROM | SELECT * FROM user LIMIT 1,3;</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
+----+--------+-------------------+ | |||
</syntaxhighlight>| | | id | name | email | | ||
+----+--------+-------------------+ | |||
| 2 | kangkk | kangkk@kangkk.com | | |||
| 3 | 365 | 365@kangkk.com | | |||
| 4 | test | test@kangkk.com | | |||
+----+--------+-------------------+ | |||
3 rows in set (0.00 sec) | |||
</syntaxhighlight>|mysql>}} | |||
查询最后一条数据。 | 查询最后一条数据。 | ||
{{Shc_out|<syntaxhighlight lang="mysql"> | {{Shc_out|<syntaxhighlight lang="mysql"> | ||
SELECT * FROM | SELECT * FROM user ORDER BY id DESC LIMIT 1;</syntaxhighlight>|<syntaxhighlight lang="bash"> | ||
+----+------+-----------------+ | |||
</syntaxhighlight>| | | id | name | email | | ||
+----+------+-----------------+ | |||
| 4 | test | test@kangkk.com | | |||
+----+------+-----------------+ | |||
1 row in set (0.00 sec) | |||
</syntaxhighlight>|mysql>}} | |||