"David T. Ashley" <[EMAIL PROTECTED]> wrote on 07/02/2006 14:03:04:
> Hi, > > I have several tables linked in various ways so that an inner join is > possible. However, at the same time and in the same SQL query, I'd also > like to query by some field values in one of the tables. > > Two quick questions: > > a)Will MySQL allow joins that involve more than two tables (in my case, > perhaps as many as 5)? > > b)Can limits on a key field be included in the join in the same SQL > statement as does the join, i.e. ... WHERE N>3 AND N<20 ... or something > like that. Yes, you can do multi-way joins, and people often do. My biggest is 3-way, but some people do at least 5-way. Beware that it is easy to specify operations which will heavily load the system if you are not careful. The constraints in the WHERE statement are *logically* and syntactically done on the huge table produced by the joins. However, the MySQL optimiser is not stupid and will perform the filter upstream of the JOIN where possible. Some experimentation and use of the EXPLAIN statement may be necessary to find the best ordering for queries. Alec -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]