Re: left join does not work, why?
| From: | Jan G.B. | Date: | Sun, 15 Mar 2009 13:47:13 +0000 |
| Subject: | Re: left join does not work, why? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-290081@lists.php.net to get a copy of this message | ||
2009/3/15 PJ <af.gourmet@videotron.ca>:
> Daniel Brown wrote:
>> On Sat, Mar 14, 2009 at 19:51, PJ <af.gourmet@videotron.ca> 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);
> 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.
>
*How* are you commenting out? Mysql accepts /* such comments */, so if
you want to transform a line in your SQL query string into a comment,
you gotta do it that way.
so this is just wrong:
$x = " select *
// from foo
from bar";
and that query would be valid
"SELECT this/*, that*/ from x"