Random retrieveal from database

How can i choose some “n” (n is gonna be fixed )records randomly from a
mysql database table from our controller?


Subashini kumar

Subashini K. wrote:

How can i choose some “n” (n is gonna be fixed )records randomly from a
mysql database table from our controller?

Use RAND() function in mysql query…
select * from TABLE_NAME order by RAND() limit N

Brijesh S. wrote:

Subashini K. wrote:

How can i choose some “n” (n is gonna be fixed )records randomly from a
mysql database table from our controller?

Use RAND() function in mysql query…
select * from TABLE_NAME order by RAND() limit N

Yeah !! cool!!! thanks a lot!!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs