当前位置:网站首页>SQL query data and sorting
SQL query data and sorting
2022-08-01 14:31:00 【Programmer over time】
I. SQL query data and sorting syntax
1. Query data syntax
Select: Query
The syntax is as follows:
(1) Use "Select" to query a field value
Select table fields from table name
(2) Use "Select" to query the values of multiple fields (the fields should be separated by ",")
Select table field, table field, table field from table name
(3) Use "Select" to query the data of the entire table
Select * from table name
Note:
(1) We want to query multiple fields to be separated by ","
(2) To query the fields of multiple different tables, we also use "," to separate different table names
When processing the Select statement, our SQL server processes the From clause first, and then processes the Select clause. Even if the Select clause comes first, its processing order is the same
2. Sort the data
If we use the "Select" statement alone, the data found will not be automatically sorted, that is, "random".
But what if we want to sort the queried data?
order By: Sort
Ascending: asc
Reverse order: desc
The syntax is as follows:
Select table fields
from table name
order by table field desc
Note:
1. By default, our sorting is "ascending", so we can omit not write "asc"
Two, practice the truth
(1) Query example
This is the data for our entire table
Now we want to find the value in the "name" field (use "Select" to query the value of a field)
(2) Use "Select" to query the values of multiple fields
(3) Use "Select" to query the data of the entire table
2. Data sorting example
- Use ascending order: sort from small to large.
By default, our ascending "asc" can be omitted.
(2) Use "desc" to: arrange "from large to small"
This is what I understand about the usage of SQL****query statement and sorting syntax. If I misunderstand, please forgive me and correct me!thank you all.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- 我寻找的方向
- 【码蹄集新手村600题】判断一个数字是否为完全平方数
- 牛客刷SQL--6
- 有限合伙人与普通合伙人的区别
- 热心肠:关于肠道菌群和益生菌的10个观点
- 通胀持续 肯尼亚粮食安全引关注
- mysql的基本使用
- Amperon IPO meeting: annual revenue of 500 million Tongchuang Weiye and China Mobile Innovation are shareholders
- 解读selenium webdriver
- Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3
猜你喜欢
【论文笔记】MiniSeg: An Extremely Minimum Network for Efficient COVID-19 Segmentation
final关键字的作用 final和基本类型、引用类型
什么是混合元编程
股票策略02 | 技术择时+行业因子+市值轮动
【每日一题】1331. 数组序号转换
PAT 1162 Postfix Expression(25)
Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3
预防和制止家庭暴力 人身安全保护令司法解释今起施行
PAT1166 Summit(25)
HTB-Shocker
随机推荐
什么是闭包?
MySQL中的行锁
170页6万字智慧能源管理平台建设方案书
易优压双驱挖掘机压路机器类网站源码 v1.5.8
性能优化——粒子优化笔记
大神们,ODPS用的是MySQL吗?
E - Red and Blue Graph(组合数学)
Wovent Bio IPO: Annual revenue of 480 million pension fund is a shareholder
全球都热炸了,谷歌服务器已经崩掉了
MySQL中字符串比较大小(日期字符串比较问题)
math.pow()函数用法[通俗易懂]
redis主从同步方式(redis数据同步原理)
E - Red and Blue Graph (Combinatorics)
【每日一题】593. 有效的正方形
分布式中的CAP原理
使用ffmpeg来查看视频的信息,fps,和width,height
The little thing about Request reuse.The research is understood, and I will report it to you.
the direction i'm looking for
2022-07-29 网工进阶(二十二)BGP-其他特性(路由过滤、团体属性、认证、AS欺骗、对等体组、子路由器、路由最大接收数量)
ThreadLocal保存用户登录信息