当前位置:网站首页>SQL learning notes (I)
SQL learning notes (I)
2022-07-03 12:53:00 【ElsaWu1998】
( This article is being updated )
Some great advanced tutorials
- SQL Advanced techniques https://zhuanlan.zhihu.com/p/139856374
Include content :SQL The writing standard of 、SQL Some advanced use skills of ( Skillfully use CASE WHEN Make statistics & to update 、 Skillfully use HAVING Clause 、 Self join 、 Skillfully use COALESCE function )、SQL Performance optimization skills . - mysql Video combat tutorial online learning - database - Frog lesson net https://www.wkcto.com/courses.html?list=mysql
Some points to think about when brushing questions
I want to master it recently SQL, But undergraduate teachers teach relatively shallow , And most of them have been forgotten , So I finished it in one day SQL Basic tutorials for , Here is an easy-to-use self-study SQL Website ( It can run in real time ): self-taught SQL network . At the same time, I also did a little practice LeetCode
This article will record the important points in the learning process , For future study reference .
Pay attention to the writing order . The typical correct sequence is as follows :
SELECT DISTINCT column, AGG_FUNC(column_or_expression) FROM mytable JOIN another_table ON mytable.column = another_table.column WHERE constraint_expression GROUP BY column HAVING constraint_expression ORDER BY column ASC/DESC LIMIT count OFFSET COUNT;If you don't have to
GROUP BYgrammar , ordinaryWHEREThat's enough. .If you want to separate statistics according to two dimensions , stay
GROUP BYJust put two inside . for example :select role,count(*),(case when Building is not null then 1 else 0 end) bn from employees group by role,bnQuery execution order :
FROMandJOIN;WHERE;GROUP BY;HAVING;SELECT;DISTINCT
If there are duplicate data rows DISTINCT Will be responsible for weight removal .ORDER BY
When the result set is determined ,ORDER BY Sort the results . because SELECT The expression in has been executed . You can use AS Alias .LIMIT / OFFSET
Last LIMIT and OFFSET Intercept some data from the sorting results .When selecting the highest data , If you need to display a null value , have access to
IFNULL(...,NULL)LIMIT The parameter of cannot be a formula , If you need to change a value, you can use the statement
SET N = N-1;If you need to update the table , Can cooperate withUPDATEUse . for example :UPDATE Salaries SET salary = CASE WHEN salary >= 10000 THEN salary * 0.9 WHEN salary < 10000 THEN salary * 1.2 ELSE salary END;
边栏推荐
- Analysis of a music player Login Protocol
- GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
- Record your vulnhub breakthrough record
- Public and private account sending prompt information (user microservice -- message microservice)
- It feels great to know you learned something, isn‘t it?
- Integer case study of packaging
- 4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
- Sword finger offer09 Implementing queues with two stacks
- Sqoop1.4.4原生增量导入特性探秘
- 【数据挖掘复习题】
猜你喜欢

【R】【密度聚类、层次聚类、期望最大化聚类】

Sword finger offer09 Implementing queues with two stacks

Quick learning 1.8 front and rear interfaces

最新版盲盒商城thinkphp+uniapp

Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward

Leetcode234 palindrome linked list

Detailed explanation of the most complete constraintlayout in history

Four problems and isolation level of MySQL concurrency

studio All flavors must now belong to a named flavor dimension. Learn more

Powerful avatar making artifact wechat applet
随机推荐
ORM use of node -serialize
Ten workplace rules
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep268
Xctf mobile--app3 problem solving
Write a simple nodejs script
Approve iPad, which wants to use your icloud account
Express abstract classes and methods
【数据库原理及应用教程(第4版|微课版)陈志泊】【第七章习题】
Enable SASL authentication for memcached
Sword finger offer14 the easiest way to cut rope
【習題七】【數據庫原理】
A large select drop-down box, village in Chaoyang District
C graphical tutorial (Fourth Edition)_ Chapter 18 enumerator and iterator: enumerator samplep340
Redhat5 installing socket5 proxy server
Sqoop1.4.4原生增量导入特性探秘
[Exercice 5] [principe de la base de données]
【习题五】【数据库原理】
如何在微信小程序中获取用户位置?
I'm too lazy to write more than one character
The foreground uses RSA asymmetric security to encrypt user information