当前位置:网站首页>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
边栏推荐
- D - Draw Your Cards(模拟)
- Amperon IPO meeting: annual revenue of 500 million Tongchuang Weiye and China Mobile Innovation are shareholders
- 微服务系统架构的演变
- [LiteratureReview]Optimal and Robust Category-level Perception: Object Pose and Shape Estimation f
- The soul asks: How does MySQL solve phantom reads?
- PAT 1167 Cartesian Tree(30)
- 什么是元编程
- 【每日一题】1331. 数组序号转换
- xmind2testcase:高效的测试用例导出工具
- Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3
猜你喜欢
随机推荐
ABC260 E - At Least One(双指针)
PAT1166 Summit(25)
Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
免费使用高性能的GPU和TPU—谷歌Colab使用教程
【每日一题】952. 按公因数计算最大组件大小
性能优化——动画优化笔记
预防和制止家庭暴力 人身安全保护令司法解释今起施行
珠海首个水环境安全监测系统上线
可观测性就是对“监控”的包装?
对标丰田!蔚来又一新品牌披露:产品价格低于20万
qt 通用ui
JSON数据转换总结(VIP典藏版)
微服务系统架构的演变
透过现象看本质,如何针对用户做好需求分析
动态模型中嵌入静态模型实践
分布式中的远程调用
股票策略02 | 技术择时+行业因子+市值轮动
我寻找的方向
Pytorch - Distributed Model Training
有谁知道pg12.5版本的数据库驱动在哪里能找到么?