On Wednesday 24 January 2007 8:07 pm, Robert Cummings wrote:

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

Sure there is.  If it's a very simple SQL statement.

I have at various times done all of the following, depending on the complexity 
of the statement in question:

SELECT id, foo, FROM foo_table WHERE id=5

(Too short to really bother with splitting up.)

SELECT id, foo, bar, baz
FROM foo_table
  INNER JOIN bar_table on a=b
  LEFT OUTER JOIN baz_table on b=c
WHERE blah
  AND stuff < narf
  OR (thingie AND other)
ORDER BY foo

SELECT a.a, a.b, a.c
    b.d, b.e, b.f
  FROM a
    INNER JOIN b ON whatever
ORDER BY a.b, a.c DESC

"Like any other programming language", or rather any language that isn't 
Python, formatting matters most to the reader, not to the program.  So, 
optimize your style for readability.  Readability is, of course, partially 
subjective so your style will differ from my style, but the key point is 
still to optimize the code for when you come back in 3-6 months to add a 
feature or find an obscure bug and don't remember what the frel you were 
doing.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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

Reply via email to