当前位置:网站首页>Basic knowledge of mysql (2)
Basic knowledge of mysql (2)
2022-07-31 04:01:00 【shortage--】
1. Sorting rules
Use ORDER BY clause to sort
ASC (ascend): ascending order
DESC (descend): descending order
ORDER BY clause in SELECTthe end of the statement.
We can use column aliases to sortSELECT employee_id,salary,salary * 12 annual_salFROM employeesORDER BY annual_sal;#Note: Column aliases can only be used in ORDER BY, not in WHERE.#The following operation reports an error!SELECT employee_id,salary,salary * 12 annual_salFROM employeesWHERE annual_sal > 81600;
Second, paging
LIMIT is used in MySQL to implement paging
Format: LIMIT [position offset,] number of rows
#Requirement: display pageSize records per page,The pageNo page is displayed:
#Formula:
SELECT * FROM table LIMIT(PageNo - 1)*PageSize,PageSize;
Note: The LIMIT clause must be placed at the end of the entire SELECT statement!
The benefits of using LIMIT
Constraining the number of returned results can reduce the network traffic of the data table and improve query efficiency.
If we know that there is only one result returned, we can use LIMIT 1 to tell the SELECT language
边栏推荐
猜你喜欢
type_traits元编程库学习
Key Technologies of Interface Testing
SIP Protocol Standard and Implementation Mechanism
pom文件成橘红色未加载的解决方案
"DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction" paper notes
端口排查步骤-7680端口分析-Dosvc服务
(8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class
扫雷游戏(c语言写)
A brief introduction to the CheckboxListTile component of the basic components of Flutter
【论文阅读】Mastering the game of Go with deep neural networks and tree search
随机推荐
(4) Recursion, variable parameters, access modifiers, understanding main method, code block
Ambiguous method call.both
$parent/$children 与 ref
el-image标签绑定点击事件后没有有用
顺序表的实现
IDEA常用快捷键与插件
【AUTOSAR-RTE】-4-Port and Interface and Data Type
PMP WeChat group daily exercises
A brief introduction to the CheckboxListTile component of the basic components of Flutter
浅识Flutter 基本组件之CheckBox组件
Summary of Huawei Distributed Storage FusionStorage Knowledge Points [Interview]
Redis uses sorted set to cache latest comments
C语言从入门到如土——数据的存储
IIR filter and FIR filter
SIP协议标准和实现机制
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
Redis implements distributed locks
qlib自动化quant
识Flutter 基本组件之showTimePicker 方法
The BP neural network