当前位置:网站首页>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 的使用


边栏推荐
猜你喜欢

(3) string

(6) Design of student information management system

The CTF introductory notes of SQL injection

Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary

VIKINGS: 1 vulnhub walkthrough

对账、结账、错账更正方法、划线更正法、红字更正法、补充登记法

Offensive and defensive world - novice MISC area 1-12

云安全笔记:云原生全链路加密

CTF之xxe

账务处理程序、记账凭证账务处理程序、汇总记账凭证账务处理程序、科目汇总表账务处理程序、会计信息化概述、信息化环境下会计账务处理的基本要求(此章出1道小题)
随机推荐
VIKINGS: 1 vulnhub walkthrough
The CTF introductory notes of SQL injection
(1) the print () function, escape character, binary and character encoding, variables, data type, the input () function, operator
Phonebook
解密:链动2+1的商业模式
GreenOptic: 1 vulnhub walkthrough
file contains vulnerabilities
成本会计的概念、产品成本核算的要求、产品成本核算的对象与成本项目、产品成本的归集和分配(可能考判断)、产品成本计算方法 (三种:产品的品种(品种法),批次(分批法),步骤(分步法))
OPENSSL基本实验以及OPENSSL详解
The focus of the Dom implementation input triggers
敏感信息泄露
一个网络安全小白鼠的学习之路——nmap的基本使用
SQL注入(7)
利用cookie获取admin权限 CTF基础题
广告电商「私域打工人」职业前景:你离月薪6万,还差多远?
12. What is JS
借贷记账法下的账户结构、借贷记账法的记账规则、借贷记账法下的账户对应关系与会计分录
(3) string
hackmyvm: controller walkthrough
hackmyvm: may walkthrough