当前位置:网站首页>mysql基础知识(二)
mysql基础知识(二)
2022-07-31 03:58:00 【荒--】
一、排序规则
使用 ORDER BY 子句排序
ASC(ascend): 升序
DESC(descend):降序
ORDER BY 子句在SELECT语句的结尾。
我们可以使用列的别名,进行排序
SELECT employee_id,salary,salary * 12 annual_sal
FROM employees
ORDER BY annual_sal;
#注意:列的别名只能在 ORDER BY 中使用,不能在WHERE中使用。
#如下操作报错!
SELECT employee_id,salary,salary * 12 annual_sal
FROM employees
WHERE annual_sal > 81600;
二、分页
MySQL中使用 LIMIT 实现分页
格式:LIMIT [位置偏移量,] 行数
#需求:每页显示pageSize条记录,此时显示第pageNo页:
#公式:
SELECT * FROM table LIMIT(PageNo - 1)*PageSize,PageSize;
注意:LIMIT 子句必须放在整个SELECT语句的最后!
使用 LIMIT 的好处
约束返回结果的数量可以 减少数据表的网络传输量 ,也可以 提升查询效率 。
如果我们知道返回结果只有1 条,就可以使用 LIMIT 1 ,告诉 SELECT 语
边栏推荐
猜你喜欢

(五)final、抽象类、接口、内部类

No qualifying bean of type question

No qualifying bean of type 问题

《DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction》论文笔记

浅识Flutter 基本组件之CheckboxListTile组件

Key Technologies of Interface Testing

SIP Protocol Standard and Implementation Mechanism

Redis implements distributed locks

pom文件成橘红色未加载的解决方案

(四)递归、可变参数、访问修饰符、理解 main 方法、代码块
随机推荐
web容器及IIS --- 中间件渗透方法1
IDEA common shortcut keys and plug-ins
LocalDate加减操作及比较大小
Just debuted "Fight to Fame", safety and comfort are not lost
Daily practice of LeetCode - palindrome structure of OR36 linked list
The use of beforeDestroy and destroyed
Select the smoke test case, and make the first pass for the product package entering QA
errno error code and meaning (Chinese)
qlib自动化quant
微软 AI 量化投资平台 Qlib 体验
RESTful api interface design specification
Web container and IIS --- Middleware penetration method 1
分布式锁以及实现方式三种
Safety 20220718
[C language] Three-pointed chess (classic solution + list diagram)
Win10 CUDA CUDNN 安装配置(torch paddlepaddle)
Daily practice of LeetCode - 138. Copy a linked list with random pointers
addressable in Golang
Learning DAVID Database (1)
Component pass value provide/inject