CREATE TABLE Class_A
(name VARCHAR(16) PRIMARY KEY,
age INTEGER,
city VARCHAR(16) NOT NULL );
CREATE TABLE Class_B
(name VARCHAR(16) PRIMARY KEY,
age INTEGER,
city VARCHAR(16) NOT NULL );
INSERT INTO Class_A VALUES('布朗', 22, '东京');
INSERT INTO Class_A VALUES('拉里', 19, '埼玉');
INSERT INTO Class_A VALUES('伯杰', 21, '千叶');
INSERT INTO Class_B VALUES('和泉', 18, '千叶');
INSERT INTO Class_B VALUES('武田', 20, '千叶');
INSERT INTO Class_B VALUES('石川', 19, '神奈川');
请问下面这两句代码同样是返回NULL
select ALL ( SELECT age
FROM Class_B
WHERE city = '东京' ) as "ALL"
select ( SELECT MIN(age)
FROM Class_B
WHERE city = '东京' ) as "MIN"
但下面这两句执行的结果却完全不一样?
①
SELECT *
FROM Class_A
WHERE age < ALL ( SELECT age
FROM Class_B
② WHERE city = '东京' );
SELECT *
FROM Class_A
WHERE age < ( SELECT MIN(age)
FROM Class_B
WHERE city = '东京' );
我看书上说对进行NULL比较操作,返回的结果都是NULL也就是Unknown,那么 ①查询和②查询都应该返回空结果可是实际上
①返回的是
name age city
---------------- ----------- ----------------
伯杰 21 千叶
布朗 22 东京
拉里 19 埼玉