Posted By

traeregan on 12/04/09


Tagged

random rand


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Order By Rand() Alternative


 / Published in: SQL
 

URL: http://www.phpfreaks.com/forums/index.php?topic=125759.0

Using subqueries...

  1. SELECT name FROM tablename
  2. WHERE id >= FLOOR( RAND( ) * ( SELECT MAX( id ) FROM tablename ) )
  3. ORDER BY id ASC
  4. LIMIT 1

Report this snippet  

You need to login to post a comment.