關於NOT IN運算子的一些特殊之處
阿新 • • 發佈:2019-02-16
IN Operator
The IN
operator tests set membership.It means "equal to any member of." The set can contain nulls, butthey are ignored. For example, the following expression testswhether a value is part of a set
of values:
letter IN ('a','b','c')
Be careful when inverting this condition. Expressions ofthe form:
value NOT IN set
yield FALSE
if the set contains anull.--如果這集合(set)包括了空值,那麼這個表示式將產生FALSE。 例如:
select dest,revenue from test where revenue not in(
select 4000 from test union select null fromdual);--此結果將返回0行。
對於子查詢:select 4000 from test union select null from dual來說,這個結果集有NULL值。
而且使用運算子NOT IN。因此WHERE 條件為FALSE。因此不會返回的行。