Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 连接条件显示不适当的结果_Database_Oracle_Join_Left Join_Where Clause - Fatal编程技术网

Database 连接条件显示不适当的结果

Database 连接条件显示不适当的结果,database,oracle,join,left-join,where-clause,Database,Oracle,Join,Left Join,Where Clause,我最近写了这个查询,在上面的查询中没有满足条件b.status='yes',status在其中显示NULL值。我想根据此条件优化我的记录。状态为“是”。请尝试以下操作: 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',status在其中显示NULL值。我想根据此条件优化我的记录。状态为“是”。

请尝试以下操作:

    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';

@请看我的最新答案。这个很好用
   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