当前位置:网站首页>Knowledge points of MySQL (7)
Knowledge points of MySQL (7)
2022-07-05 17:31:00 【Flag: roll king!】
One 、 Process control functions
Process processing functions can be based on different conditions , Perform different processes , Can be in SQL Statement to implement different conditional choices .MySQL The process processing functions in mainly include IF()、IFNULL() and CASE() function .
IF usage :
mysql> select if(1>0,' correct ',' error '),if(1<0,' correct ',' error ') from dual;
mysql> select if(1>0,' error ',' correct '),if(1<0,' error ',' correct ') from dual;
Two 、 Encryption and decryption functions
The encryption and decryption function is mainly used to encrypt and decrypt the data in the database , Prevent data from being stolen by others . These functions are very useful in ensuring database security .
Be careful : stay mysql8.0 in ,password(),encode()、decode() Abandoned .
mysql> select md5('mysql'),sha('mysql'),md5(md5('mysql')) from dual;
( Be careful :md5 It's irreversible )
3、 ... and 、MySQL Information functions
MySQL There are some built-in functions that can be queried MySQL Information functions , These functions are mainly used to help database developers or operation and maintenance personnel better maintain the database .
mysql> select version(),connection_id(),database(),schema(),user(),current_user() from dual;
Four 、 Other functions
MySQL Some functions in cannot classify them specifically , But these functions are MySQL In the process of development and operation and maintenance of .
about format Say when n Less than or equal to 0 when , Then only the integer part
mysql> select format(123.123,2),format(123.123,-2) from dual;
conv:
mysql> select conv(16,10,2),conv(8888,10,16),conv(null,10,2) from dual;
inet_aton,inet_ntoa:
mysql> select inet_aton('192.168.1.100'),inet_ntoa(3232235876) from dual;( and 3232235876 By 192 multiply 256 Of 3 Power , add 168 multiply 256 Of 2 Power , add 1 multiply 256, Plus 100)
5、 ... and 、 Aggregate functions
Aggregate functions ( Group function ): Is a function that summarizes a set of data , The input is a set of data , The output is a single value .
1, Common aggregate functions
1)AVG / SUM
mysql> select avg(id),sum(id) from employees;
2)MAX / MIN( For numeric types 、 String type 、 Field or variable of date time type )
mysql> select max(id),min(id) from employees;
3)COUNT
(1) effect : Calculate the number of times the specified field appears in the query structure
mysql> select count(id) from employees;
(2) Be careful : When calculating the number of occurrences of the specified field , It is not calculated NULL It's worth it .
(3)AVG=SUM / COUNT
mysql> select avg(id),sum(id)/count(id) from employees;
2,group by Use
mysql> select id from employees group by id;
Be careful :
1,select The fields of non group functions appearing in must be declared in group by in , conversely ,group by The fields declared in may not appear in select in .
2,group by The statement is in from after 、where Back 、order by front 、limit front
3,MySQL in group by Use in with rollup, You can get a new average result
mysql> select id from employees group by id with rollup;
边栏推荐
- Thoughtworks 全球CTO:按需求构建架构,过度工程只会“劳民伤财”
- Embedded-c language-6
- Using C language to realize palindrome number
- MySQL之知识点(七)
- Complete solution instance of Oracle shrink table space
- The second day of learning C language for Asian people
- In depth understanding of redis memory obsolescence strategy
- Mysql5.6 parsing JSON strings (supporting complex nested formats)
- 张平安:加快云上数字创新,共建产业智慧生态
- ThoughtWorks global CTO: build the architecture according to needs, and excessive engineering will only "waste people and money"
猜你喜欢
Check the WiFi password connected to your computer
漏洞复现----48、Airflow dag中的命令注入(CVE-2020-11978)
MySQL之知识点(六)
How to write a full score project document | acquisition technology
Complete solution instance of Oracle shrink table space
Judge whether a string is a full letter sentence
The second day of learning C language for Asian people
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
MySQL之知识点(七)
mongodb(快速上手)(一)
随机推荐
Machine learning 01: Introduction
CMake教程Step2(添加库)
MYSQL group by 有哪些注意事项
Embedded UC (UNIX System Advanced Programming) -1
ICML 2022 | Meta propose une méthode robuste d'optimisation bayésienne Multi - objectifs pour faire face efficacement au bruit d'entrée
忽米沄析:工业互联网标识解析与企业信息系统的融合应用
C#(Winform) 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件
张平安:加快云上数字创新,共建产业智慧生态
ThoughtWorks global CTO: build the architecture according to needs, and excessive engineering will only "waste people and money"
goto Statement
c#图文混合,以二进制方式写入数据库
激动人心!2022开放原子全球开源峰会报名火热开启!
2022年信息系统管理工程师考试大纲
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
CVPR 2022 best student paper: single image estimation object pose estimation in 3D space
漫画:有趣的【海盗】问题
CMake教程Step1(基本起点)
Cartoon: interesting [pirate] question
Embedded-c Language-5
WebApp开发-Google官方教程