On Mar 18, 5:56 pm, Scott David Daniels <scott.dani...@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...@acm.org -- http://mail.python.org/mailman/listinfo/python-list