List:General Discussion« Previous MessageNext Message »
From:Gerald L. Clark Date:June 30 2006 2:54pm
Subject:Re: Multiple joins
View as plain text  
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.

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
Multiple joinsSteffan A. Cline30 Jun
  • Re: Multiple joinsGerald L. Clark30 Jun
    • Re: Multiple joinsSteffan A. Cline30 Jun
  • Re: Multiple joinsBrent Baisley30 Jun