This is what I finally settled on. It seems to work well.
select m.*, d.discussion, d.discussion_id, u.user_id, u.icon, u.nick_name
from forums_messages m
left join forums_topics t
on m.topic_id = t.topic_id
left join forums_discussions d
on t.discussion_id = d.discussion_id
left join users u
on m.user_id = u.user_id
where m.topic_id = 1;
Thanks
Steffan
---------------------------------------------------------------
T E L 6 0 2 . 5 7 9 . 4 2 3 0 | F A X 6 0 2 . 9 7 1 . 1 6 9 4
Steffan A. Cline
Steffan@stripped Phoenix, Az
http://www.ExecuChoice.net USA
AIM : SteffanC ICQ : 57234309
Lasso Partner Alliance Member
---------------------------------------------------------------
> From: "Gerald L. Clark" <gerald_clark@stripped>
> Date: Fri, 30 Jun 2006 09:54:14 -0500
> To: "Steffan A. Cline" <steffan@stripped>
> Cc: <mysql@stripped>
> Subject: Re: Multiple joins
>
> Steffan A. Cline wrote:
>> What am I missing here?
>>
>> select m.*, d.discussion, d.discussion_id, u.user_id, t.topic_id
>> from forums_messages
>> left join forums_members m, forums_discussions d, users u, forums_topics t
>> on m.topic_id = t.topic_id, t.discussion_id = d.discussion_id
>> where m.topic_id = "1";
>>
>> Is it legal to do multiple joins like this?
>>
>>
>>
>>
>> Thanks
>>
>> Steffan
>
>
> forum_messages does not take part in any selection or any where clause.
> You have 5 tables listed, with only 4 of them appearing in 2 disjointed,
> and improperly formed joins.
> From the comma separated table list after a LEFT JOIN, I am not sure
> whether you intend them to be LEFT JOINs or INNER JOINs.
>
> Try:
> SELECT fields
> FROM file1
> LEFT JOIN file2 ON something
> INNER JOIN file3 ON something
> INNER JOIN file4 ON something
> INNER JOIN file5 ON something
> WHERE somecondition
>
>
>
>
> --
> Gerald L. Clark
> Supplier Systems Corporation