【问题标题】:pl/sql exclusion join with two conditionpl/sql 排除连接有两个条件
【发布时间】:2012-06-18 02:07:08
【问题描述】:

如果行有,我想排除加入(相同的工具和相同的配方) 当我运行以下代码时

select a.tool, a.recipe
from dual a
where a.tool NOT IN (select b.tool from daul2 b)
and a.recipe NOT IN (select b.recipe from dual2 b) 

它首先过滤工具,然后是配方,但我希望程序同时检查它。

有没有办法同时检查两列?

【问题讨论】:

  • 选择“dual”以外的示例表名可能是个好主意,因为这是 Oracle 中的一个特殊表。

标签: sql join oracle11g


【解决方案1】:

我不完全确定我理解您的要求。我的猜测是你想要任何一个

SELECT a.tool, a.recipe
  FROM table1 a
 WHERE (a.tool, a.recipe) NOT IN (SELECT b.tool, b.recipe
                                    FROM table2 b)

SELECT a.tool, a.recipe
  FROM table1 a
 WHERE NOT EXISTS( SELECT 1
                     FROM table2 b
                    WHERE a.tool = b.tool 
                      AND a.recipe = b.recipe )

如果这不是您想要的,您能否发布一些示例数据并解释您要排除和包含的内容?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多