第十一课 使用子查询
一、子查询过滤
SELECT id,rank
FROM score
WHERE id in (SELECT id
FROM inf
WHERE age = 22)
注意:子查询只能是单列
二、作为计算字段
SELECT
id,
age,
(SELECT COUNT(*)
FROM score
WHERE inf.id = score.id) AS c_score
FROM inf
ORDER BY age;