SQL Multiple JOINS to same table
Posted on 2008-02-11
I've got this query:
SELECT View_CMS_Tree_Joined.*, CONTENT_Event.*, act1.*, act2.*
INNER JOIN CONTENT_Event
ON View_CMS_Tree_Joined.DocumentForeignKeyValue = CONTENT_Event.[eventID]
LEFT JOIN custom_activity AS act1
ON CONTENT_Event.[EventActivity] = act1.[activityID]
LEFT JOIN custom_activity AS act2
ON CONTENT_Event.[EventActivity2] = act2.[activityID]
It is returning the correct data - but the field names returned for act1 and act2 are identical - which makes it impossible to distinguish between act1.field1 and act2.field1. I'm obviously doing something wrong here.
Thanks for any help.