[thelist] MySQL query with two left joins

Steve Lewis nepolon at worlddomination.net
Wed Jul 2 12:52:55 CDT 2003


Sarah wrote:

> I am just going to include one of the counts in the main query, and 
> then, as I loop through the results, run individual queries for the 
> other count.

I would recommend performing your first left join to generate a temp 
table, then perform your second left join between the temp table and the 
third table in your query to generate your record set.  Doing this is 
essentially duplicating the purpose of a view in other DBs.  It will 
perform better and keep the query logic relatively isolated in the DB 
until you can get MySQL 4.1 running and use a subquery.

Steve



More information about the thelist mailing list