Nested Queries In Rails
Join the DZone community and get the full member experience.
Join For Free
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\"))"
Database
Opinions expressed by DZone contributors are their own.
Comments