Oracle SQL-基于concat的外部联接

Oracle SQL-基于concat的外部联接,sql,oracle,join,outer-join,Sql,Oracle,Join,Outer Join,我需要交叉连接两个表,但连接条件为: Select FutureInventory.Item, To_Number(Concat(Location, Channel_Id)) Location, From V_CUST_FUTURE_INV_POSITION FutureInventory, xx_Item_Loc_Info_V ItemLoc Where FutureInventory.Item(+) = ItemLoc.Item And

我需要交叉连接两个表,但连接条件为:

Select FutureInventory.Item,
       To_Number(Concat(Location, Channel_Id)) Location,
  From V_CUST_FUTURE_INV_POSITION FutureInventory,
       xx_Item_Loc_Info_V         ItemLoc
 Where FutureInventory.Item(+) = ItemLoc.Item
   And To_Number(Concat(Location, Channel_Id))(+) = ItemLoc.Loc;
我想用ItemLoc.Loc将列外部连接到_编号(Concat(位置,通道_Id))
在Oracle中,如果要放置(+)符号进行外部联接,可以使用适当的
join
类型,就像在所有其他数据库中一样。我认为你想要的逻辑是:

select FutureInventory.Item,
       To_Number(Concat(Location, Channel_Id)) as Location,
from xx_Item_Loc_Info_V ItemLoc LEFT JOIN
     V_CUST_FUTURE_INV_POSITION FutureInventory,
     on FutureInventory.Item = ItemLoc.Item AND
        To_Number(Concat(Location, Channel_Id)) = ItemLoc.Loc;

首先,使用显式连接语法-旧的
(+)
很难阅读,也很容易出错。第二,使用
|
操作符而不是
CONCAT
函数-同样,更易于阅读。因此,我们以

Select FutureInventory.Item,
       To_Number(Location || Channel_Id) Location,
  From xx_Item_Loc_Info_V ItemLoc
  LEFT OUTER JOIN V_CUST_FUTURE_INV_POSITION FutureInventory,
    ON FutureInventory.Item = ItemLoc.Item And
       To_Number(Location || Channel_Id) = ItemLoc.Loc

样本数据、期望的结果以及对逻辑的清晰解释都会有所帮助。