Re: LEFT joins
| From: | franciccio | Date: | Thu, 20 Jan 2005 18:02:15 +0000 |
| Subject: | Re: LEFT joins | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.db php.db |
| Request: | Send a blank email to php-db+get-38232@lists.php.net to get a copy of this message | ||
Jochem Maas ha scritto:
Han wrote:Why are you so intrested in LEFT JOIN? I cn't help much since i don't know the schema of the db and i can't see clear the meaning of the tables in the query. Anyway try this: <SQL> SELECT b.fldName,Hmm, still no luck. Thanks for the help. I think I'll have to break theyou mean that it still times out? crashes mysql? maybe the table (tc_countries) is corrupt? try doing a repair.select up into 2 selects and throw the results of the first into arrays. Didn't want to do it like that, but it's gonna be quicker now.if at first you don't succeed... hack ;-) <snip> try removing the ORDER BY Clause:OR.... SELECT b.fldName,SELECT b.fldName,b.fldEmail, b.fldCountryCode, d.fldCode as FCode, b.fldMobile, a.fldTime as Time, c.fldUsernameFROM tblSubscribersChoices a LEFT JOIN tblUser c ON c.fldClientID = a.fldChoice LEFT JOIN tblSubscribers b ON b.fldID = a.fldClientID LEFT JOIN tc_countries d ON d.fldCode = b.fldCountryCode ORDER BY c.fldUsername ASCb.fldEmail, b.fldCountryCode, d.fldCode as FCode, b.fldMobile, a.fldTime as Time, c.fldUsername as UsernameFROM tblSubscribersChoices a LEFT JOIN tblUser c ON c.fldClientID = a.fldChoice LEFT JOIN tblSubscribers b ON b.fldID = a.fldClientID LEFT JOIN tc_countries d ON d.fldCode = b.fldCountryCode ORDER BY Username ASCand if that works but doesn't give you repeat records try adding the DISTINCT keyword after SELECT. <snip>
b.fldEmail,
b.fldCountryCode,
d.fldCode as FCode,
b.fldMobile,
a.fldTime as Time,
c.fldUsername as Username
FROM tblSubscribersChoices a, tblUser c, tblSubscribers b,
tc_countries d
WHERE c.fldClientID = a.fldChoice AND b.fldID = a.fldClientID AND
d.fldCode = b.fldCountryCode
ORDER BY Username ASC
</SQL>
Bye