Hello, 
 
I am trying to figure out a problem I am having with a query involving
multiple joins but am not having much luck.
I currently have this query working:
 
db1 LEFT JOIN db2 ON db1.files_groupId = db2.group_id 
       LEFT JOIN db3 ON db1.files_userId = db3.user_id 
 
Basically the above is taking the group id and user id from db1 and
getting their names from the appropriate db.
What I would like to be able to do though is join db3 (user) on to db1
again but using a different ON value (a different user id in the same
record). Is this possible? 
 
I have tried aliasing the db3:
db1 LEFT JOIN db2 ON db1.files_groupId = db2.group_id 
       LEFT JOIN db3 AS user1 ON db1.files_userId = user1.user_id
       LEFT JOIN db3 AS user2 ON db1.files_otherUserId = user2.user_id
WHERE .......
The above query does not cause a MySQL error, however there are no
values passed for the requested labels of db3 e.g user2.user_name.
I have tried printing out mysql_fetch_assoc($result) and from what I can
see the user db doesn't get joined on again but wipes all results of the
other user join.
 
Thanks for any help offered.
 
Will
 
 

Reply via email to