【问题标题】:find the IDs that are in A but not in B查找在 A 中但不在 B 中的 ID
【发布时间】:2023-02-01 15:18:42
【问题描述】:

在A和B两张表中,找出在A中但不在B中的ID(请使用in运算符来解决这道题) enter image description here

我是甲骨文的新手。我该如何编写这段代码。请帮助我的朋友。

【问题讨论】:

    标签: oracle oracle-sqldeveloper


    【解决方案1】:

    实际上,它是NOT IN

    SQL> select a.id
      2  from a
      3  where a.id not in (select b.id from b where b.id is not null);
    
            ID
    ----------
             8
             7
    

    不过,更简单的选择是使用 minus 集合运算符:

    SQL> select id from a
      2  minus
      3  select id from b;
    
            ID
    ----------
             7
             8
    
    SQL>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-20
      • 1970-01-01
      • 2020-07-04
      • 2018-07-05
      • 2021-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多