当前位置:网站首页>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;
边栏推荐
- Design of electronic clock based on 51 single chip microcomputer
- Cmake tutorial step6 (add custom commands and generate files)
- CMake教程Step3(添加库的使用要求)
- 这个17岁的黑客天才,破解了第一代iPhone!
- How MySQL uses JSON_ Extract() takes JSON value
- Embedded-c Language-4
- [Web attack and Defense] WAF detection technology map
- The second day of learning C language for Asian people
- High number | summary of calculation methods of volume of rotating body, double integral calculation of volume of rotating body
- Zhang Ping'an: accélérer l'innovation numérique dans le cloud et construire conjointement un écosystème industriel intelligent
猜你喜欢
MYSQL group by 有哪些注意事项
Use of ThinkPHP template
Kafaka technology lesson 1
机器学习01:绪论
7.Scala类
The second day of learning C language for Asian people
一个满分的项目文档是如何书写的|得物技术
MySQL queries the latest qualified data rows
ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
CVPR 2022 best student paper: single image estimation object pose estimation in 3D space
随机推荐
漏洞复现----48、Airflow dag中的命令注入(CVE-2020-11978)
flask解决CORS ERR 问题
Rider 设置选中单词侧边高亮,去除警告建议高亮
统计php程序运行时间及设置PHP最长运行时间
查看自己电脑连接过的WiFi密码
【7.7直播预告】《SaaS云原生应用典型架构》大咖讲师教你轻松构建云原生SaaS化应用,难题一一击破,更有华为周边好礼等你领!
Three traversal methods of binary tree
华为云云原生容器综合竞争力,中国第一!
Zhang Ping'an: accélérer l'innovation numérique dans le cloud et construire conjointement un écosystème industriel intelligent
Redis+caffeine two-level cache enables smooth access speed
Is it safe and reliable to open futures accounts on koufu.com? How to distinguish whether the platform is safe?
CMake教程Step6(添加自定义命令和生成文件)
漫画:有趣的【海盗】问题
[Web attack and Defense] WAF detection technology map
Cartoon: interesting [pirate] question
Summary of optimization scheme for implementing delay queue based on redis
Embedded-c Language-5
IDEA 项目启动报错 Shorten the command line via JAR manifest or via a classpath file and rerun.
这个17岁的黑客天才,破解了第一代iPhone!
Read the basic grammar of C language in one article