Re: LEFT joins

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



BTW: Hans please use 'reply to all' so that the rest of the list can see your replies (+ it makes me feel less like you personal help-desk ;-).

...on to the reply proper:

Han wrote:
Hi, thanx for replying.

It still times out when I use either of those alternatives.

can you tell what exactly the script is timing out on - i.e. are you sure its the call to the DB? you SQL _may_ not be the most efficient way of doing it (not that I know or anything) but I can tell you that I have a query on a production site which involves 16 JOINS and that works fine [I can here you laughing in the bach there ;-)] - actually it had 33 JOINS but there is a hard limit to the number of joins per statement in the version of MySQL the site uses so I had to split the query into 2!


also have you tried running the complete query/queries directly in a MySQL console? i.e. remove PHP from the equation to determine if the problem is actually the SQL. please tell us whether the statements work ok when you run them directly.

I've tried changing all the JOINs around and nothing works.

Post the table deinfitions to the list + a recap on what you are trying to get as a result.


I thought maybe there's a logic problem going on?

some kind of problem anyway ;-)

<snip>

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

in the orderby clause you apply backticks to the table alias 'c', which you don't do anywhere else. its a long shot but try removing those backticks.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux