Yes there are. First do as you have written, although your syntax is a bit wrong but the email compiler forgives such stuff :-)
> SELECT table1.bunch, table2.of, table3.stuff FROM table1 > INNER JOIN table2 ON table2.some_id > INNER JOIN table3 ON table3.some_id > WHERE table1.some_id = table2.some_id AND table1.some_id = table3.some_id; should have been: > SELECT table1.bunch, table2.of, table3.stuff FROM table1 > INNER JOIN table2 ON table2.some_id = table1.FK > INNER JOIN table3 ON table3.some_id = table1.FK > WHERE table1.some_id = table2.some_id AND table1.some_id = table3.some_id; IMO you confuse the logic if you combine joins with wheres. You make it very hard to understand what's occurring and even harder to debug it. Store all your join logic in the join clauses, then reserve the where for precisely what you mean. For example: SELECT Table1.Stuff INNER JOIN Table2 ON Table1.FK = Table2.PK INNER JOIN Table3 ON Table2.FK = Table3.PK (etc.) WHERE Table1.PK = myVar In this sort of construction, the logic is far more apparent than in a construction which blurs the joins and wheres. Just my $.02. Arthur ----- Original Message ----- From: "Josh Trutwin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 03, 2002 3:57 PM Subject: Re: Is there Examples and Documents on joining tables? > > > Is there a document that compiles examples on different ways of joining > > two or more tables? I found a few on > > http://www.mysql.com/doc/en/JOIN.html but they do not cover joining more > > than two tables. > > > > Thanks for any suggestions. > > I wish there were more examples as well! > > I use this for multi-table joins: > > SELECT table1.bunch, table2.of, table3.stuff FROM table1 > INNER JOIN table2 ON table2.some_id > INNER JOIN table3 ON table3.some_id > WHERE table1.some_id = table2.some_id AND table1.some_id = table3.some_id; > > Not sure if this the best way or not, but it works... > > Anyone with more experience care to contribute? Are there optimum ways to > join multiple tables? > > Josh > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php