MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Michael T. Babcock Date:January 22 2003 7:25pm
Subject:Re: three table join
View as plain text  
Tab Alleman wrote:

>SELECT SomeStuff
>FROM Table1 AS T1
>LEFT JOIN Table2 AS T2 ON T1.PK = T2.FK1
>RIGHT JOIN Table3 AS T3 ON T2.FK2 = T3.PK
>WHERE T1.PK=999

Either right-join it or reverse the table order (because you're not 
asking for data from "t1 that is like t2 that is like t3 that is like 
999", you're asking for data "from t3 which has data ... in t2 which has 
data ... in t1 which has pk 999"

You have to think of the queries 'in order', left to right ... so that 
your LEFT join means what it should mean :).  I rarely do right joins in 
small queries; it makes more sense to just reverse the query.

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