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

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...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to