MySQL 不常用操作

MySQL not common operate

Posted by HaoDu on March 29, 2020

多字段 in

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SELECT
	department.NAME AS Department,
	employee.name as Employee,
	Salary
FROM
	employee
	JOIN department ON departmentId = department.id 
WHERE
	 (salary, departmentId)  IN (
	SELECT
	max(salary) salary ,
		departmentId
		
	FROM
		employee 
	GROUP BY
	departmentId 
	)

any all 关键字

1
2
select * from Weather where Temperature > all(select Temperature from Weather where id <3)
select * from Weather where Temperature > any(select Temperature from Weather where id <3)