连接多个表 ORACLE
Joining multiple tables ORACLE
SELECT *
FROM STORE
,MATERIAL
,STOREBIN
,VENDOR
,MATERIALPRICE
,SD
WHERE STOREBIN.STOREBINID(+) = SD.STOREBINID
AND SD.VENDORID = VENDOR.VENDORID(+)
AND MATERIAL.MATERIALID = MATERIALPRICE.MATERIALID(+)
AND STORE.STOREID = SD.STOREID
我这里有这个简单的查询,但我想将 (+) 符号更改为连接,这怎么可能?我在想:
RIGHT JOIN SD ON STOREBIN.STOREBINID = SD.STOREBINID
LEFT JOIN VENDOR ON VENDOR.VENDORID = SD.VENDORID
LEFT JOIN MATERIALPRICE ON MATERIALPRICE.MATERIAID = MATERIAL.MATERIALID
WHERE STORE.STOREID = SD.STOREID
但这似乎不太对,因为我需要将每个 table 加入不同的 table。
这将是等效的(如果我们还添加您提到的其他条件):
FROM
SD
INNER JOIN STORE as S
on S.STOREID = SD.STOREID
INNER JOIN MATERIAL as M
ON M.MATERIALID = SD.MATERIALID
LEFT JOIN STOREBIN as SB
ON SB.STOREBINID = SD.STOREBINID
LEFT JOIN VENDOR as V
ON V.VENDORID = SD.VENDORID
LEFT JOIN MATERIALPRICE as MP
ON MP.MATERIALID = M.MATERIALID
SELECT *
FROM STORE
,MATERIAL
,STOREBIN
,VENDOR
,MATERIALPRICE
,SD
WHERE STOREBIN.STOREBINID(+) = SD.STOREBINID
AND SD.VENDORID = VENDOR.VENDORID(+)
AND MATERIAL.MATERIALID = MATERIALPRICE.MATERIALID(+)
AND STORE.STOREID = SD.STOREID
我这里有这个简单的查询,但我想将 (+) 符号更改为连接,这怎么可能?我在想:
RIGHT JOIN SD ON STOREBIN.STOREBINID = SD.STOREBINID
LEFT JOIN VENDOR ON VENDOR.VENDORID = SD.VENDORID
LEFT JOIN MATERIALPRICE ON MATERIALPRICE.MATERIAID = MATERIAL.MATERIALID
WHERE STORE.STOREID = SD.STOREID
但这似乎不太对,因为我需要将每个 table 加入不同的 table。
这将是等效的(如果我们还添加您提到的其他条件):
FROM
SD
INNER JOIN STORE as S
on S.STOREID = SD.STOREID
INNER JOIN MATERIAL as M
ON M.MATERIALID = SD.MATERIALID
LEFT JOIN STOREBIN as SB
ON SB.STOREBINID = SD.STOREBINID
LEFT JOIN VENDOR as V
ON V.VENDORID = SD.VENDORID
LEFT JOIN MATERIALPRICE as MP
ON MP.MATERIALID = M.MATERIALID