具有内部联接的查询:
Select
O.ORDER_KEY, O.ORDER_SOURCE,
-------, ---
FROM
Table_1, Table_2, Table_3
where
TABLE_1.SK = TABLE_2.SK AND TABLE_2.SK = TABLE_3.SK and many more;
上述查询返回10000行。
我想添加另一个表,但同时我不想从table_2中删除订单。为此,我使用了left_outer_join:
Select
O.ORDER_KEY, NVL(O.ORDER_SOURCE, WROA.ORDER_SOURCE) AS ORDER_SOURCE,
-------, ---
FROM
Table_1, Table_2, Table_3, Table_4
where
TABLE_1.SK = TABLE_2.SK AND TABLE_2.SK = TABLE_3.SK AND
TABLE_2.ORDER = TABLE_4.ORDER(+);
上述查询返回200行。
为什么不返回10000行?我错过了什么?如何添加一个左外连接的条件影响那么多行?
答案 0 :(得分:0)
可能是因为您定义了where子句。您要添加的新表,此表中的列是where子句的一部分?如果是,则使用该列的内联视图来查看它是否为您提供了正确的结果。
答案 1 :(得分:0)
我的意思是ANSI 92 ......
SELECT O.ORDER_KEY, NVL(O.ORDER_SOURCE, WROA.ORDER_SOURCE) AS ORDER_SOURCE, ...
FROM Table_1
INNER JOIN Table_2
ON TABLE_1.SK = TABLE_2.SK
INNER JOIN Table_3
ON TABLE_2.SK = TABLE_3.SK AND
LEFT JOIN Table_4
ON TABLE_2.ORDER = TABLE_4.ORDER
WHERE ...