LEFT joins
| From: | Han | Date: | Wed, 12 Jan 2005 12:15:37 +0000 |
| Subject: | LEFT joins | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-38117@lists.php.net to get a copy of this message | ||
Hi,
I'm having a problem with some joins.
My code is : --
SELECT b.fldName, b.fldEmail, b.fldCountryCode, b.fldMobile, a.fldTime as Time, c.fldUsername FROM
tblSubscribersChoices a INNER JOIN tblUser c on a.fldChoice=c.fldClientID LEFT JOIN tblSubscribers b
on a.fldClientID = b.fldID ORDER BY
c.fldUsername ASC
Now this works fine.
But, I'm trying to tally the country code with it's actual name (which is held in
tc_countries). So I thought if I add another LEFT JOIN at the end of the query : --
SELECT b.fldName, b.fldEmail, b.fldCountryCode, d.fldCode as FCode, b.fldMobile, a.fldTime as Time,
c.fldUsername FROM tblSubscribersChoices a INNER JOIN tblUser c on a.fldChoice=c.fldClientID LEFT
JOIN tblSubscribers b on a.fldClientID = b.fldID LEFT JOIN tc_countries d on b.fldCountryCode =
d.fldCode ORDER BY c.fldUsername ASC
But this just times out as it's matching too many matches.
What am I doing wrong???
Han.