当前位置:网站首页>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 语
边栏推荐
- Just debuted "Fight to Fame", safety and comfort are not lost
- Notes on the establishment of the company's official website (6): The public security record of the domain name is carried out and the record number is displayed at the bottom of the web page
- pom文件成橘红色未加载的解决方案
- type_traits metaprogramming library learning
- Can‘t load /home/Iot/.rnd into RNG
- Safety 20220718
- No qualifying bean of type 问题
- 「 每日一练,快乐水题 」1331. 数组序号转换
- 【AUTOSAR-RTE】-4-Port和Interface以及Data Type
- Port inspection steps - 7680 port analysis - Dosvc service
猜你喜欢
[Paper reading] Mastering the game of Go with deep neural networks and tree search
IDEA comment report red solution
Based on the local, linking the world | Schneider Electric "Industrial SI Alliance" joins hands with partners to go to the future industry
浅识Flutter 基本组件之CheckBox组件
(4) Recursion, variable parameters, access modifiers, understanding main method, code block
BP神经网络
Why don't you programmers make a living off your own projects?And have to work for someone else?
No qualifying bean of type question
Component pass value provide/inject
安全20220712
随机推荐
(八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
【论文阅读】Mastering the game of Go with deep neural networks and tree search
(8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class
SocialFi 何以成就 Web3 去中心化社交未来
SQL Interview Questions (Key Points)
No qualifying bean of type 问题
Implementation of a sequence table
BP神经网络
log level and print log note
已解决:不小心卸载pip后(手动安装pip的两种方式)
Safety 20220712
问题1:给你1-10的列表,实现列表输出,单数在左边,双数在右边。
With 7 years of experience, how can functional test engineers improve their abilities step by step?
Just debuted "Fight to Fame", safety and comfort are not lost
els block to the right
(4) Recursion, variable parameters, access modifiers, understanding main method, code block
Distributed locks and three implementation methods
Zotero如何删除自动生成的标签
LocalDate加减操作及比较大小
端口排查步骤-7680端口分析-Dosvc服务