如何在Oracle 8i中创建内部联接和左联接

时间:2018-12-14 17:16:19

标签: oracle oracle8i

我正在尝试创建一个Oracle 8i QUERY,其中包含多个条件的内部联接以及多个条件的左联接。但是,我一直没有正确结束SQL命令。我的经验主要是在T-SQl上,所以如果这很明显,请提前道歉。

SELECT TRANS.CUSTOMER_NUMBER AS "AR CUST", CUST.CUSTOMER_NUMBER AS 
"CUSTNUM", CUSTA.FVE_NUMBER AS "FVE"
FROM FINANCE.AR_TRANSACTIONS  TRANS
JOIN FINANCE.CUSTOMERS CUST
ON (TRANS.CUSTOMER_NUM = CUST.CUSTOMER_NUM
AND TRANS.COMPANY_NUM = CUST.COMPANY_NUM)
LEFT JOIN FINANCE.CUSTOMER_ADDRESSES CUSTA
ON (TRANS.FVE_NUMBER = CUSTA.FVE_NUMBER
AND TRANS.COMANY_NUM = CUSTA.CUSTOMER_NUM )
WHERE ROWNUM < 5; 

1 个答案:

答案 0 :(得分:1)

8i不支持ANSI '92联接语法left, right, inner, full outer, cross join syntax,您必须使用(+)表示法...

类似...

SELECT TRANS.CUSTOMER_NUMBER AS "AR CUST"
     , CUST.CUSTOMER_NUMBER AS "CUSTNUM"
     , CUSTA.FVE_NUMBER AS "FVE"
FROM FINANCE.AR_TRANSACTIONS  TRANS
   , FINANCE.CUSTOMERS CUST
   , FINANCE.CUSTOMER_ADDRESSES CUSTA
WHERE TRANS.CUSTOMER_NUM = CUST.CUSTOMER_NUM
  AND TRANS.COMPANY_NUM = CUST.COMPANY_NUM
  AND TRANS.FVE_NUMBER = CUSTA.FVE_NUMBER(+)
  AND TRANS.COMANY_NUM = CUSTA.CUSTOMER_NUM(+)
  AND ROWNUM < 5