Re: left join does not work, why?

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

 



2009/3/15 PJ <af.gourmet@xxxxxxxxxxxx>:
>> -----Original Message-----
>> From: Jan G.B. [mailto:ro0ot.w00t@xxxxxxxxxxxxxx]
>> so this is just wrong:
>> $x = " select *
>> // from foo
>> from bar";
>> and that query would be valid
>> "SELECT this/*, that*/ from x"
>>
> It took ma a bit of thinking, I must say, but the answer is simple:
> You cannot do comment - out's (for that is what this was really about)
> within astatement or declaration! I was commenting out two JOINs within
> a $sql = "SELECT ...... " declaration that was split into several lines
> and it didn't occur to me that you cannot just comment out a part of a
> declaration or statement that spans several lines. So, if you comment
> out one part the rest will still be parsed.

well, actually you could write my example with as much "newlines"
(whitespace) as you want.
$x = "SELECT
/* JOIN x ON a=b
*/
this FROM
that";

... is valid and mysql will parse it correct as "select this from that".

> There's a reason, then why
> the HTML specification requires that " delimited statements cannot be
> split over several lines.  Hope I said all that correctly. :-)
>

not really correct. the above sql statement is correct, because PHP
has no problem with newlines in a string encapsulated in ", just like
mysql.
but I think it's not a goog coding style to have newlines, tabs and
alike in a mysql-query; it messes up the logs.
I would do it that way:
$x = "foo"
//      . " unused"
        . " bar";


byebye

-- 
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