oracle sql 中的行内视图可以在查询中包含 "not in" 子句吗?

Can in line views in oracle sql contain "not in" clause in the query?

例如

select *
from t1 
inner join (select * from t2 where t2.id not in (select ID from t2 where city="Paris"))

我尝试搜索 Google。有很多例子,但 none 其中没有使用 in。此外,没有为内嵌视图指定限制。

Oracle 在 FROM 子句 "inline views" 中调用子查询。

这些是通用的 SELECT 查询。它们可以包含 NOT IN 和子查询。您的查询的问题是缺少 ON 子句以及对字符串常量使用双引号:

select *
from t1 inner join
     (select *
      from t2
      where t2.id not in (select ID from t2 where city = 'Paris')
---------------------------------------------------------^ single quotes
     ) t2
     on t1.? = t2.?
-----^ on clause

注意:我不鼓励您对子查询使用 NOT IN,因为如果 any 返回值为 NULL,它们将无法按预期工作。 (如果是这种情况,则不会返回任何行。)

我建议改用 NOT EXISTS