MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Michael T. Babcock Date:January 15 2003 1:29pm
Subject:Re: three table join
View as plain text  
I've wanted to post this query example a few times (and I hope I got it 
right; mornings aren't my best time) ... multiple JOINs:

     SELECT stuff
       FROM table1
  LEFT JOIN table2
         ON =
  LEFT JOIN table3
         ON =
      WHERE other_conditions

You can repeat that as many levels as you want (performance depends on 
indexing and the optimizer).  You need to think in terms of what would 
be equal to what between tables in the correct result row.  So if you 
would do a secondary sub-select of "SELECT fk from table2 where ..." 
then you end up with a left join like above.

Michael T. Babcock
C.T.O., FibreSpeed Ltd.

three table joinJosh L Bernardini15 Jan
  • Re: three table joinMichael T. Babcock15 Jan
  • Re: three table joinBrent Baisley15 Jan
RE: three table joinTab Alleman15 Jan
  • Re: three table joinHarald Fuchs16 Jan
  • Re: three table joinMichael T. Babcock22 Jan
RE: three table joinDiana Soares15 Jan