当前位置:网站首页>mysql 原生语句点滴学习记录
mysql 原生语句点滴学习记录
2022-08-02 03:26:00 【陌潇】
点滴sql记录
一、IF使用方法
IF 表达式 IF( expr1 , expr2 , expr3 )
expr1 的值为 TRUE,则返回值为 expr2 expr1
的值为FALSE,则返回值为 expr3
如下:

二、group by 分组之后查找重复的项(HAVING)
在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与聚合函数一起使用。
HAVING 子句可以让我们筛选分组后的各组数据。
查找phone不为空,且重复的手机号,原始数据:
sql 和执行后的结果:

三、Case两种格式:简单Case函数和Case搜索函数。
1、简单Case函数
case sex
when '1' then '男'
when '2' then '女'
else '其他' end
2、Case搜索函数
case
when sex = '1' then '男'
when sex = '2' then '女'
else '其他' end

case用法详细介绍地址:https://blog.csdn.net/weixin_44688973/article/details/118808601
四、group by分组之后取出最大值
原始数据
使用sql查询: SELECT id, sex, age, max(age) AS age_en FROM USER GROUP BY sex
五、month 和 year 的使用


边栏推荐
猜你喜欢

PHP deserialization vulnerability

The roll call system and array elements find maximum and minimum values for sorting of objects

hackmyvm-random walkthrough

一个网络安全小白鼠的学习之路—nmap高级用法之脚本使用

Shuriken: 1 vulnhub walkthrough

CTF入门笔记之ping

(1) the print () function, escape character, binary and character encoding, variables, data type, the input () function, operator

CTF-Neting Cup Past Topics

成本会计的概念、产品成本核算的要求、产品成本核算的对象与成本项目、产品成本的归集和分配(可能考判断)、产品成本计算方法 (三种:产品的品种(品种法),批次(分批法),步骤(分步法))

云安全笔记:云原生全链路加密
随机推荐
hackmyvm: controller walkthrough
成本会计的概念、产品成本核算的要求、产品成本核算的对象与成本项目、产品成本的归集和分配(可能考判断)、产品成本计算方法 (三种:产品的品种(品种法),批次(分批法),步骤(分步法))
GreenOptic: 1 vulnhub walkthrough
The learning path of a network security mouse - the basic use of nmap
机器学习1
PHP Foundation March Press Announcement Released
CTF之xxe
A code audit notes (CVE - 2018-12613 phpmyadmin file contains loopholes)
Turn trendsoft/capital amount of Chinese capital library
A network security guinea pig's learning path - scripting of advanced usage of nmap
17. JS conditional statements and loops, and data type conversion
4. The form with the input
The focus of the Dom implementation input triggers
[symfony/finder] The best file manipulation library
Eric target penetration test complete tutorial
CTF入门之php文件包含
file contains vulnerabilities
真·杂项:资本论阅读笔记(随缘更新)
Masashi: 1 vulnhub walkthrough
Google Hacking