当前位置:网站首页>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 .
边栏推荐
- Analysis of updatechild principle of widget update mechanism of fluent
- 外包干了四年,人直接废了。。。
- Tencent Interviewer: How did binder get its system services?
- mysql自帶的性能測試工具mysqlslap執行壓力測試
- Oracle技术分享 oracle 19.14升级19.15
- 钉钉开放平台-小程序开发实战(钉钉小程序客户端)
- 软件调试测试的十大重要基本准则
- Verrouillage de lecture et d'écriture pour la synchronisation des fils
- 用eclipse连mysql数据库出错然后出现图中的话是咋回事呀
- 钉钉开放平台-小程序开发实战(钉钉小程序服务器端)
猜你喜欢

In 2022, what professional competitions can college students majoring in automation, electrical engineering and automation participate in?

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)

Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优

The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond

Matplotlib multi line chart, dot scatter chart

High performance computing center roce overview
![[Flink] a brief analysis of the writing process of Flink sort shuffle](/img/27/01e95b44df46d8bfcb36ab1d746cc2.jpg)
[Flink] a brief analysis of the writing process of Flink sort shuffle

ABP framework Practice Series (II) - Introduction to domain layer

线程同步之条件变量

Tencent Interviewer: How did binder get its system services?
随机推荐
Restful API interface design standards and specifications
win10 系统打开的软件太小,如何变大(亲测有效)
mysql自带的性能测试工具mysqlslap执行压力测试
How much do you make by writing a technical book? To tell you the truth, 2million is easy!
mysql自帶的性能測試工具mysqlslap執行壓力測試
The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond
Binary search method
An error occurred using the connection to database 'on server' 10.28.253.2‘
MySQL est livré avec l'outil de test de performance MySQL lap pour effectuer des tests de résistance
Three level menu applet
763. dividing alphabetic intervals
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
刷题记录Day01
What if the serial port fails to open when the SCM uses stc-isp to download software?
IEDA 突然找不到了compact middle packages
Sorting out the knowledge points of the renderview renderobject parentdata of the shuttle
【Flink】Flink Sort-Shuffle写流程简析
MySQL's built-in performance testing tool, mysqlslap, performs stress testing
asp.net网页选择身份进行登录的简单代码,asp连接数据库,使用asp:Panel、asp:DropDownList控件
如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup