DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Alexey has posted 28 posts at DZone. View Full User Profile

Nested Queries In Rails

04.22.2011
| 5340 views |
  • submit to reddit
        
Entry.where(:id => Entry.select('max(id) id').arel).to_sql

=> "SELECT     \"entries\".* FROM       \"entries\"  WHERE     (\"entries\".\"id\" IN (SELECT     max(id) id FROM       \"entries\"))"