mysql中limit使用
时间:2022-05-06
本文章向大家介绍mysql中limit使用,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
mysql中没有top,替而代之的是limit关键字,具体使用方法如下:
mysql> select * from test;
+----+------+-----+----------+--------------+
| id | name | age | tel | address |
+----+------+-----+----------+--------------+
| 1 | aaaa | 12 | aaaaaa | aaaaaaaaa |
| 2 | bbbb | 12 | 12312312 | asgdsf |
| 3 | bbb | 23 | 123423 | asdfsafd |
| 5 | asdf | 23 | asfdsd | asdgesadg |
| 7 | sadf | 23 | asgsdg | asgsdfsafsdf |
+----+------+-----+----------+--------------+
5 rows in set (0.00 sec)
mysql> select * from test limit 2,5
-> ;
+----+------+-----+--------+--------------+
| id | name | age | tel | address |
+----+------+-----+--------+--------------+
| 3 | bbb | 23 | 123423 | asdfsafd |
| 5 | asdf | 23 | asfdsd | asdgesadg |
| 7 | sadf | 23 | asgsdg | asgsdfsafsdf |
+----+------+-----+--------+--------------+
3 rows in set (0.00 sec)
mysql> select * from test limit 2,4;
+----+------+-----+--------+--------------+
| id | name | age | tel | address |
+----+------+-----+--------+--------------+
| 3 | bbb | 23 | 123423 | asdfsafd |
| 5 | asdf | 23 | asfdsd | asdgesadg |
| 7 | sadf | 23 | asgsdg | asgsdfsafsdf |
+----+------+-----+--------+--------------+
3 rows in set (0.00 sec)
mysql> select * from test order by name limit 2,4;
+----+------+-----+----------+--------------+
| id | name | age | tel | address |
+----+------+-----+----------+--------------+
| 3 | bbb | 23 | 123423 | asdfsafd |
| 2 | bbbb | 12 | 12312312 | asgdsf |
| 7 | sadf | 23 | asgsdg | asgsdfsafsdf |
+----+------+-----+----------+--------------+
3 rows in set (0.00 sec)
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- SSM项目频繁打成war包部署,使用tomcat和maven实现热部署配置
- Laravel 视图使用入门
- 基于 Go 协程实现图片马赛克应用(上):同步版本
- Blade 模板引擎入门篇
- 基于 Go 协程实现图片马赛克应用(下):并发重构
- Python入门教程笔记(三)数组
- Greenplum集群Master与Standby相互切换
- Java基础知识三问—百度真题
- 访问权限导致toString返回空BUG分享
- 基于 Spring Boot 的在线考试系统
- Redis系列:高可用哨兵方案部署
- linux或windows环境下pytorch的安装与检查验证(解决runtimeerror问题)
- Linux 查看历史命令并执行的方法
- 在 awk 中使用循环
- 移植busybox构建最小根文件系统的步骤详解