1 posts in total

Active Record

Posts tagged

Retrieving random row from a table via ActiveRecord

1 min read

There are multiple ways to retrive a random row from a table: This is fast and requires no custom SQL. All this does is count number of rows in a table and select one row at some offset while still having the table ordered by primary key. It uses offset (limit), not ID number, s ...