暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysql基础 limit 取前三条数据

  •        OS : Ubuntu 18.04.1 LTS
  •        DBMS : mysql 8.0.12

示例

stu@Ubuntu:~$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 38 Server version: 8.0.12 MySQL Community Server - GPL Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use db_chinese_medicine; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> desc t_fruit; +--------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(15) | NO | UNI | NULL | | | count | int(11) | NO | | NULL | | | price | decimal(6,3) | NO | | NULL | | | is_sales | tinyint(1) | NO | | 1 | | | note | varchar(255) | YES | | 无 | | | gmt_create | datetime | NO | | NULL | | | gmt_modified | datetime | NO | | NULL | | +--------------+------------------+------+-----+---------+----------------+ 8 rows in set (0.01 sec) mysql> select * from t_fruit; +----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+ | id | name | count | price | is_sales | note | gmt_create | gmt_modified | +----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+ | 1 | 甜瓜 | 10 | 3.210 | 1 | 无 | 2018-10-27 19:42:56 | 2018-10-27 19:42:56 | | 2 | 乌梅 | 20 | 5.430 | 1 | 无 | 2018-10-27 19:46:21 | 2018-10-27 19:46:21 | | 3 | 樱桃 | 30 | 6.540 | 1 | 无 | 2018-10-27 19:46:48 | 2018-10-27 19:46:48 | | 4 | 甘蔗 | 50 | 7.650 | 0 | 无 | 2018-10-27 19:51:13 | 2018-10-27 19:51:13 | | 5 | 菠萝蜜 | 50 | 8.760 | 1 | 菠萝蜜和菠萝是什么关系? | 2018-10-27 19:55:44 | 2018-10-27 19:55:44 | | 6 | 无花果 | 100 | 8.760 | 1 | 无 | 2018-10-27 19:57:48 | 2018-10-27 19:57:48 | | 7 | 山葡萄 | 200 | 5.550 | 1 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 | | 8 | 无漏子 | 5 | 3.320 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 | | 9 | 五敛子 | 12 | 6.010 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 | | 10 | 藕 | 80 | 10.200 | 0 | 无 | 2018-10-27 20:11:07 | 2018-10-27 20:11:07 | +----+-----------+-------+--------+----------+------------------------------------+---------------------+---------------------+ 10 rows in set (0.00 sec) mysql> select * from t_fruit limit 0,3; +----+--------+-------+-------+----------+------+---------------------+---------------------+ | id | name | count | price | is_sales | note | gmt_create | gmt_modified | +----+--------+-------+-------+----------+------+---------------------+---------------------+ | 1 | 甜瓜 | 10 | 3.210 | 1 | 无 | 2018-10-27 19:42:56 | 2018-10-27 19:42:56 | | 2 | 乌梅 | 20 | 5.430 | 1 | 无 | 2018-10-27 19:46:21 | 2018-10-27 19:46:21 | | 3 | 樱桃 | 30 | 6.540 | 1 | 无 | 2018-10-27 19:46:48 | 2018-10-27 19:46:48 | +----+--------+-------+-------+----------+------+---------------------+---------------------+ 3 rows in set (0.00 sec) mysql> exit Bye stu@Ubuntu:~$

学习资源


欢迎各位同学一起来交流学习心得!

最后修改时间:2021-12-16 18:07:49
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论