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 table1.fk = table2.pk
LEFT JOIN table3
ON table2.fk = table3.pk
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.
http://www.fibrespeed.net/~mbabcock



---------------------------------------------------------------------
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

Reply via email to