2015-05-05 44 views

回答

0
SELECT oPers.first_name AS ownerFirstName 
    , aPers.first_name AS agentFirstName 
    .... 
FROM properties AS p 
LEFT JOIN owners AS po ON p.property_id = po.property_id 
LEFT JOIN people AS oPers ON po.person_id = oPers.person_id 
LEFT JOIN agents AS pa ON p.property_id = pa.property_id 
LEFT JOIN people AS aPers ON pa.person_id = aPers.person_id 
; 
+0

感謝您的回答,我已經嘗試過了,它工作正常,但問題是衝突,因爲我得到了(例如名字字段2次,一個代理和一個所有者。)我需要像owner_firstname和agent_firstname這樣的結果。 – Makis