Style formating of multiline query, advise
someone
petshmidt at googlemail.com
Wed Mar 18 13:06:44 EDT 2009
On Mar 18, 5:56 pm, Scott David Daniels <Scott.Dani... at Acm.Org> wrote:
> someone wrote:
> > what is good :) style for multiline queries to database?...
> > query = """ SELECT * FROM (
> > SELECT a.columna, a.columnb, a.iso
> > FROM all a
> > WHERE (a.name = LOWER(%s)) ) AS c
> > JOIN other as b on c.gid = b.id
> > WHERE class = 'A'
> > ORDER BY population DESC
> > LIMIT %s;"""
>
> Also, for SQL, (A) why are you using nested joins?, and
inner select produce smaller set which is then joined with other
table, kind a optimization
> (B) always show what columns you want as output. SELECT * is a hack
> to make interactive use easier, not a durable way to write queries.
Yes, my original question was about formatting. It's not original
query (only a part).
But thank you anyway!
>
> query = """SELECT a.columna, a.columnb, a.iso, b.id, ...
> FROM all AS a, other as b
> WHERE a.name = LOWER(%s)
> AND a.gid = b.id
> AND b.class = 'A'
> ORDER BY population DESC
> LIMIT %s;"""
>
> --Scott David Daniels
> Scott.Dani... at Acm.Org
More information about the Python-list
mailing list