当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
What is a closure?
Gradle系列——Gradle测试,Gradle生命周期,settings.gradle说明,Gradle任务(基于Groovy文档4.0.4)day2-3
细读《阿里测试之道》
只知道SQL数据库?又一国产数据库语言诞生了
可观测性就是对“监控”的包装?
Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3
搭建ntp时间服务器(安装sql2000配置服务器失败)
win10+Qt5.15.2 realizes low-power bluetooth control
珠海首个水环境安全监测系统上线
math.pow()函数用法[通俗易懂]
leetcode.26 删除有序数组中的重复项(set/直接遍历)
MySQL中根据日期进行范围查询
The role of the final keyword final and basic types, reference types
布隆过滤器bloom
datetime64[ns]转化为datetime
直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践
性能优化——渲染优化笔记
the direction i'm looking for
Longkou united chemical registration: through 550 million revenue xiu-mei li control 92.5% stake
视频传输协议(常用的视频协议)









