0

我有一个 Oracle 命令

Select offers.OFR_STAT,OFFER_DETAILS.*,PrevData.*
From offers
INNER JOIN OFFER_DETAILS
    ON OFFER_DETAILS.OFFER_ID=offers.OFFER_ID
INNER JOIN (
    SELECT InnerOfrDtl.*
    FROM OFFER_DETAILS as InnerOfrDtl 
    WHERE InnerOfrDtl.offer_id=offers.offer_id
) AS PrevData
    ON PrevData.SCHEDULE_TYPE=OFFER_DETAILS.SCHEDULE_TYPE

运行时,我收到一条错误消息“缺少右括号”。在这里,我想使用内部联接的子查询。

4

3 回答 3

1

尝试在右括号之后和之前删除 AS PrevData。据我了解,Oracle 不允许使用关键字 AS 作为表别名。


该查询不需要子查询。你可以写:

SELECT o.OFR_STAT, d.*, p.*
  FROM offers o
  JOIN Offer_Details d ON d.Offer_ID = o.Offer_ID
  JOIN Offer_Details p
    ON p.Offer_ID = o.Offer_ID
   AND p.Schedule_Type = d.Schedule_Type

我并不完全相信这个查询是有道理的,但这完全是另一回事。

于 2012-07-16T06:54:03.207 回答
0

旧版本的 Oracle(肯定是 8i,也可能是 9i)在显式 INNER JOIN 方面存在问题。用隐式(非ANSI?)内部连接替换它们可以解决问题。

https://forums.oracle.com/forums/thread.jspa?threadID=328028

于 2012-11-16T00:29:53.337 回答
0

删除AS子查询的关键字,Oracle 不支持:

Select offers.OFR_STAT,OFFER_DETAILS.*,PrevData.*
From offers
INNER JOIN OFFER_DETAILS
    ON OFFER_DETAILS.OFFER_ID=offers.OFFER_ID
INNER JOIN (
    SELECT InnerOfrDtl.*
    FROM OFFER_DETAILS as InnerOfrDtl 
    WHERE InnerOfrDtl.offer_id=offers.offer_id
) PrevData  -- <<<< here is the change
    ON PrevData.SCHEDULE_TYPE=OFFER_DETAILS.SCHEDULE_TYPE
于 2012-07-16T06:55:56.040 回答