Profile photo for Dan Lenski

The fact that you can't rearrange "clauses" in select statements can drive me a little bit crazy.

When I have to write a query like this...

  1. SELECT ft.id, bt.id, func(col3) 
  2. FROM foo_table ft 
  3. LEFT JOIN bar_table bt on (ft.frob=bt.baz) 
  4. JOIN other_table ot on (bt.baz=ot.whatsit) 
  5. WHERE ft.wee in (1,2,3) 
  6. GROUP BY ft.id, bt.id 


Usually the output columns (results) are
not what I think of first. Often the tables and the join conditions are what I think about first. Sometimes the grouping or filtering is what I think about first. I'm always having to jump around and go back and edit things out-of-order when writing a query... and it gets messier when there are subqueries.

I wish I could rearrange a big query like this, for example...

  1. SELECT FROM foo_table ft 
  2. LEFT JOIN bar_table bt on (ft.frob=bt.baz) 
  3. JOIN other_table ot on (bt.baz=ot.whatsit) 
  4. WHERE ft.wee in (1,2,3) 
  5. OUTPUT ft.id, bt.id, func(col3) 
  6. GROUP BY ft.id, bt.id 


The
SQLAlchemy ORM for Python does allow building up SQL queries in mostly-arbitrary order, which is one of my favorite features :)

View 4 other answers to this question
About · Careers · Privacy · Terms · Contact · Languages · Your Ad Choices · Press ·
© Quora, Inc. 2025