当前位置:网站首页>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
边栏推荐
猜你喜欢

openEuler 社区完成首批顾问专家聘用,共同为社区的发展贡献力量

性能测试入门指南

倪光南:openEuler已达国际同类社区水准

Gradle series - Gradle tests, Gradle life cycle, settings.gradle description, Gradle tasks (based on Groovy documentation 4.0.4) day2-3

AtCoder Beginner Contest 261 D - Flipping and Bonus

【码蹄集新手村600题】判断一个数字是否为完全平方数

超全!全国近90所大学考研报录比汇总!

207.数组序号转换

SQL查询数据以及排序

什么是混合元编程
随机推荐
魔众短链接系统 v3.9.0
datetime64[ns]转化为datetime
MySQL中字符串比较大小(日期字符串比较问题)
牛客刷SQL--6
性能优化——渲染优化笔记
AtCoder Beginner Contest 261 D - Flipping and Bonus
E - Red and Blue Graph (Combinatorics)
2022图片在线加水印源码
【码蹄集新手村600题】判断一个数字是否为完全平方数
E - Red and Blue Graph(组合数学)
倪光南:openEuler已达国际同类社区水准
透过现象看本质,如何针对用户做好需求分析
微信UI在线聊天源码 聊天系统PHP采用 PHP 编写的聊天软件,简直就是一个完整的迷你版微信
荣信文化通过注册:年营收3.8亿 王艺桦夫妇为实控人
What is a closure?
stm32l476芯片介绍(nvidia驱动无法找到兼容的图形硬件)
【论文笔记】MiniSeg: An Extremely Minimum Network for Efficient COVID-19 Segmentation
Performance Optimization - Rendering Optimization Notes
2022年5月20日最全摸鱼游戏导航
SQL查询语句之查询数据