Re: most powerful php editor

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

 



At 9:07 PM -0500 1/24/07, Robert Cummings wrote:
Dear Mr Lynch, normally I highly respect your commentary on the list,
but today I think you've been-a-smoking the crackpipe a tad too much.

There is no way in hell one long line of SQL is easier to read than
formatted SQL that clearly delineates the clause structure.

SELECT A.field1 AS afield1, A.field2 AS afield2, B.field1 AS bfield1,
B.field2 AS bfield2, C.field1 AS cfield1, C.field2 AS cfield2, D.field1
AS dfield1, D.field2 AS dfield2 FROM tableA as A LEFT JOIN tableB AS B
ON B.fee = A.foo LEFT JOIN tableC AS C ON C.fii = B.fee LEFT JOIN tableD
AS D ON D.fuu = C.fii WHERE A.foo = 'someValue' ORDER BY afield1 ASC,
cfield2 ASC

The above line "should" be on one line, but my email client might
autowrap it. Either way, the following is formatted and is much clearer.

SELECT
    A.field1 AS afield1,
    A.field2 AS afield2,
    B.field1 AS bfield1,
    B.field2 AS bfield2,
    C.field1 AS cfield1,
    C.field2 AS cfield2,
    D.field1 AS dfield1,
    D.field2 AS dfield2
FROM
    tableA as A
        LEFT JOIN tableB AS B ON
            B.fee = A.foo
        LEFT JOIN tableC AS C ON
            C.fii = B.fee
        LEFT JOIN tableD AS D ON
            D.fuu = C.fii
WHERE
    A.foo = 'someValue'
ORDER BY
    afield1 ASC,
    cfield2 ASC


While the above is contrived, most of us know such examples happen quite
often in the wild. Not only is it easier to read, but the task of adding
or removing selected fields is trivial.

Cheers,
Rob.


Ahem to that!

You're on a roll brother -- keep going.

Can I get another Ahem?!

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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