【问题标题】:Joining condition showing inappropriate result加入条件显示不合适的结果
【发布时间】:2017-08-04 08:55:41
【问题描述】:
    SELECT   a.name,
             nvl(c.bill_amount,0),
             b.status
        FROM  table_1 a left outer join table_2 b
        ON  a.name = b.name and
           b.status = 'YES'
        left outer join table_3 c on B.phone_number = C.phone_number
             AND B.email = C.email
             where 
             a.VALID = 'Y';

我最近写了这个查询,上面的查询中没有满足条件 b.status = 'yes' 并且状态显示为 NULL 值。我想根据这个条件来完善我的记录 b.status ='yes'。

【问题讨论】:

    标签: database oracle join left-join where-clause


    【解决方案1】:

    尝试以下方法:

       SELECT  a.name, nvl(c.bill_amount,0), b.status
       FROM  table_1 a left outer join table_2 b
       ON  a.name = b.name
       left outer join table_3 c on b.phone_number = c.phone_number
       where 
       a.VALID = 'Y' and
       b.status = 'YES' and
       b.email = c.email
    

    【讨论】:

    • @Akshay - 请查看我的更新答案。这很好用
    猜你喜欢
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多