2014-02-20 104 views
0

這裏是我的查詢:問題與DQL外連接

SELECT r.pLastName, r.pFirstName, r.ppLocation, a.createdDate, a.appointmentDate, a.hour, a.minute, a.ampm, p.firstName, p.lastName, a.reason, pl.firstName as oncologyPhysicianFirstName, pl.lastName as oncologyPhysicianLastName 
FROM MainReferralCaptureBundle:Appointment a, MainReferralCaptureBundle:Referral r, MainReferralCaptureBundle:Physician p 
RIGHT OUTER JOIN MainReferralCaptureBundle:PhysicansLocations pl WITH pl.physicansLocationsId = r.ppName 
WHERE a.referralId = r.id 
AND r.submittedBy = :user 
AND r.rpId = p.id 
ORDER BY a.appointmentDate DESC 

我收到以下錯誤:

QueryException: [Syntax Error] line 0, col 366: Error: Expected end of string, got 'RIGHT' 

如果我做的:

SELECT r.pLastName, r.pFirstName, r.ppLocation, a.createdDate, a.appointmentDate, a.hour, a.minute, a.ampm, p.firstName, p.lastName, a.reason, pl.firstName as oncologyPhysicianFirstName, pl.lastName as oncologyPhysicianLastName 
     FROM MainReferralCaptureBundle:Appointment a, MainReferralCaptureBundle:Referral r, MainReferralCaptureBundle:Physician p 
     LEFT OUTER JOIN MainReferralCaptureBundle:PhysicansLocations pl WITH pl.physicansLocationsId = r.ppName 
     WHERE a.referralId = r.id 
     AND r.submittedBy = :user 
     AND r.rpId = p.id 
     ORDER BY a.appointmentDate DESC 

我得到:

ORA-00904: "R0_"."PP_NAME": invalid identifier 

我不確定發生了什麼。 ppName是一個有效的標識符。請注意,我使用Oracle作爲我的後端。

回答

0

發現,我不得不改變我的FROM子句中的順序:

FROM MainReferralCaptureBundle:Appointment a, MainReferralCaptureBundle:Physician p, MainReferralCaptureBundle:Referral r 

現在一切正常。