如何使用LEFT OUTER和RIGHT OUTER Join将以下查询转换为SQL 92?
SELECT in.ItemNo, ip.ItemPrice, c.CustomerName
FROM inventories in, InventoryPrice ip, Customer c
WHERE in.itemno * = ip.itemno
AND ip.CustId = * c.CustId
答案 0 :(得分:1)
select
in.ItemNo
,ip.ItemPrice
,c.CustomerName
from inventories as in
left join InventoryPrice as ip on ip.itemno = in.itemno
right join Customer as c on ip.CustId = c.CustId
请注意,旧版连接代码上的反向语法会导致混淆左侧 - 然后右侧连接。这实际上似乎是遗留代码中的一个错误,但是如果不精确地了解数据结构就无法确定..
答案 1 :(得分:-2)
SELECT in.ItemNo, ip.ItemPrice, c.CustomerName
FROM inventories AS in
LEFT JOIN InventoryPrice AS ip ON ip.itemno = in.itemno
LEFT JOIN Customer AS c ON ip.CustId = c.CustId