当前位置:网站首页>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;
边栏推荐
- In depth understanding of redis memory obsolescence strategy
- Oracle Recovery Tools ----oracle数据库恢复利器
- WR | 西湖大学鞠峰组揭示微塑料污染对人工湿地菌群与脱氮功能的影响
- 世界上最难的5种编程语言
- Cartoon: interesting pirate problem (full version)
- ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
- Embedded UC (UNIX System Advanced Programming) -3
- stirring! 2022 open atom global open source summit registration is hot!
- 漫画:寻找无序数组的第k大元素(修订版)
- Machine learning 02: model evaluation
猜你喜欢
Learn about MySQL transaction isolation level
33:第三章:开发通行证服务:16:使用Redis缓存用户信息;(以减轻数据库的压力)
VBA驱动SAP GUI实现办公自动化(二):判断元素是否存在
一文了解MySQL事务隔离级别
Oracle Recovery Tools ----oracle数据库恢复利器
The second day of learning C language for Asian people
winedt常用快捷键 修改快捷键latex编译按钮
URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
一个满分的项目文档是如何书写的|得物技术
随机推荐
mysql中取出json字段的小技巧
First day of learning C language
The third lesson of EasyX learning
Is it safe for China Galaxy Securities to open an account? How long can I buy stocks after opening an account
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
Redis+caffeine two-level cache enables smooth access speed
Three traversal methods of binary tree
Matery主题自定义(一)黑夜模式
基于Redis实现延时队列的优化方案小结
Rider 设置选中单词侧边高亮,去除警告建议高亮
漫画:一道数学题引发的血案
C # realizes crystal report binding data and printing 3-qr code barcode
关于mysql中的json解析函数JSON_EXTRACT
ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
世界上最难的5种编程语言
编译libssh2报错找不到openssl
Beijing internal promotion | the machine learning group of Microsoft Research Asia recruits full-time researchers in nlp/ speech synthesis and other directions
Cartoon: looking for the k-th element of an unordered array (Revised)
About JSON parsing function JSON in MySQL_ EXTRACT
[Web attack and Defense] WAF detection technology map