Re: left join does not work, why?

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

 



Daniel Brown wrote:
> On Sat, Mar 14, 2009 at 19:51, PJ <af.gourmet@xxxxxxxxxxxx> wrote:
>   
>> $sql1 = "SELECT b.id, b.title, b.sub_title, b.descr, b.comment,
>> b.bk_cover, b.copyright, b.ISBN, b.language, b.sellers, c.publisher, <---
>> CONCAT_WS(' ', first_name, last_name) AS Author
>> FROM book AS b
>> LEFT JOIN book_author AS ab ON b.id = ab.bookID
>> LEFT JOIN author AS a ON ab.authID=a.id
>> LEFT JOIN book_publisher as abc ON b.id = abc.bookID // <---
>> LEFT JOIN publishers AS c ON abc.publishers_id = c.id // <---
>> ORDER BY title ASC ";
>> $result1 = mysql_query($sql1, $db);
>> $bookCount = mysql_num_rows($result1);
>>     
>
>     For this and future problems of a similar nature, the quickest and
> easiest way to start debugging is to change the mysql_query() line to
> output the error.  Like so:
>
> <?php
> // ....
> $result1 = mysql_query($sql1,$db) or die("SQL: ".$sql1."\n".mysql_error());
> // ....
> ?>
>
>     If the query fails on $sql1, PHP runs the 'or' as a failure
> fallback and dies by printing the SQL query given and MySQL's error
> response.
>   
Thank you for that. I had not used that as I thought that
error_reporting(E_ALL);
ini_set('display_errors', 1);
would be enough.   =-O

The error reported now is to check the syntax near the commented out lines.
So, what is going on here? I understood that when the lines are
commented out they are not lprocessed.
When I deleted the commented out lines the errors went away.
This does not make sense and obviously could be very misleading in
debugging.


-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- pj@xxxxxxxxxxxxx
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux