子查询 有两种 一种是在from中
在from中相当于省去一张字段表
SELECT ... FROM(subquery)name...
SELECT col
FROM (
SELECT a+b AS col
FROM t1)
SELECT t3.ol
ROM (
SELECT a+b AS col
FROM t1
UNION ALL
SELECT c+d AS cal
FROM t2
) t3
另外一种是在where中操作
在where中的子查询相当于条件单字段 所以做不了多字段表(纯属个人理解)
SELECT *
FROM A
WHERE A.a IN (SELECT foo FROM B);
其他支持的types 有 EXISTS and NOT EXISTS
SELECT A
FROM T1
WHERE EXISTS(SELECT B FROM )
.....
时间: 2024-10-31 08:27:45