title: 07-Null-Subquery
date: 2023-12-27
status: DONE
tags:
- MySQL
- NOTE
- Lec7
author:
- AllenYGY
created: 2023-12-27T01:37
updated: 2024-03-21T21:49
publish: True
Null-Subquery
WHERE attribute IS NULL
Different aggregation functions treat NULL values differently.
If NULL values and non-NULL values are mixed,
If the group only consists of NULL values,
如果NULL与非NULL的属性混合 那么所有aggregation function会忽略 NULL
如果只有NULL,那么count() return 0,其他aggragation function return NULL
SELECT staff_id FROM staff WHERE (staff_rating>5) IS UNKNOWN
如果某个 attribute = NULL 那么他的逻辑判断结果 为 UNKNOWN
OR:
AND:
NOT:
Subqueries can be in all of SELECT, FROM, and WHERE clauses.
In the FROM clause, users need to indicate some tables.
A “SELECT…FROM…WHERE…” query returns a temporary table. (The type is matched.)