当前位置:网站首页>SQL related knowledge - DQL
SQL related knowledge - DQL
2022-06-26 04:05:00 【Code Xiaoyou】
1.DQL: Look up the records in the table
select * from Table name
grammar :
select
Field list
from
List of table names
where
List of conditions
group by
Grouping field
having
Conditions after components
order by
Sort
limit
Paging limit
2. Basic query
1. Multiple field queries
select Field name 1, Field name 2...from Table name ;
* Be careful :
If you query all fields , You can use * Instead of the field list
2. Remove duplication
distinct
3. Calculated column
1. Generally, four operations can be used to calculate the values of some columns .( Generally, only numerical calculation will be carried out ).
2.ifnull( expression 1, expression 2):null Operations involved , The results are all null
expression 1: Which field needs to determine whether it is null, If the field is null, Just use the expression 2 Replace .
4. names
as:as You can omit it , Use spaces .
3. Conditions of the query
1.where Clause followed by condition
2. Operator
>,<,<=,>=,=,<>( It's not equal to )
BETWEEN...AND...
IN( aggregate )
LIKE: Fuzzy query
1._: Any single character
2.%: More than one arbitrary character
IS NULL
AND perhaps &&
OR perhaps ||
not or |
4. Sequential query
grammar :order by Clause
order by Sort field 1 sort order 1, Sort field 2 sort order 2....
sort order :
ASC: Ascending , default .
DESC: Descending .
Be careful :
If there are multiple sorting conditions , The condition value of the current edge is the same , To judge the second condition
5. Aggregate functions
Aggregate functions : Take a column of data as a whole , Do the longitudinal calculation
1.count: Calculate the number of
1. Generally, non empty columns are selected : Primary key
2.count(*)
2.max: Calculate the maximum
3.min: Calculate the minimum
4.sum: The calculation and
5.avg: Calculate average
* Be careful : The calculation of aggregate functions , exclude NULL value .
Solution :
1. Select columns that do not contain non null to calculate
2.IFNULL function
6. Group query
1. grammar :group by Grouping field ;
2. Be careful :
1. Fields to be queried after grouping : Grouping field , Aggregate functions
2.where and having The difference between :
1.where Limit before grouping , If you don't do that , They don't participate in the grouping .having Limit after grouping , If the result is not satisfied , It won't be found out
2.where You can't follow an aggregate function ,having We can judge the aggregate function .
7. Paging query
1. grammar :limit Index started , Number of queries per page ;
2. The formula : Index started = ( The current number of pages - 1)* Number of entries per page
Sample code :
Three pieces of data per page :
select * from students limit 0,3;-- first page select * from students limit 3,3;-- The second page select * from students limit 6,3;-- The third page3.limit It's a MySQL Peculiar .
边栏推荐
- 【MySQL】 MySQL 导出数据库
- 力扣79单词搜索
- [QT] dialog box
- 2020 summary: industrial software development under Internet thinking
- I/O 虚拟化技术 — UIO Framework
- Getting started with flask
- XML parsing bean tool class
- Nailing open platform - applet development practice (nailing applet server side)
- Matplotlib multi line chart, dot scatter chart
- win10 系统打开的软件太小,如何变大(亲测有效)
猜你喜欢

Spark - 一文搞懂 parquet

神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习

MapReduce执行原理记录

Force buckle 515 Find the maximum value in each tree row

ABP framework Practice Series (III) - domain layer in depth

How does virtual box virtual machine software accelerate the network speed in the virtual system?

【QT】资源文件导入

Yolov5 improvements: replace the backbone

商城风格也可以很多变,DIY 了解一下

The style of the mall can also change a lot. DIY can learn about it
随机推荐
[Flink] a brief analysis of the writing process of Flink sort shuffle
Conditional variables for thread synchronization
ASP. Net core introduction
Force buckle 515 Find the maximum value in each tree row
763. 划分字母区间
I/O 虚拟化技术 — VFIO
Open source! Vitae model brushes the world's first again: the new coco human posture estimation model achieves the highest accuracy of 81.1ap
Yolov5 improvements: replace the backbone
Wechat applet is bound to a dynamic array to implement a custom radio box (after clicking the button, disable the button and enable other buttons)
Open camera anomaly analysis (I)
chrome页面录制,重放功能
Use soapUI to access the corresponding ESB project
線程同步之讀寫鎖
1.基础关
线程同步之条件变量
面了个字节拿25k出来的测试,算是真正见识到了基础的天花板
如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup
Restful API interface design standards and specifications
Introduction Guide to the flutterplugin plug-in in the actual combat of flutter
Li Kou 79 word search