Order By Rand() Alternative


/ Published in: SQL
Save to your folder(s)

Using subqueries...


Copy this code and paste it in your HTML
  1. SELECT name FROM tablename
  2. WHERE id >= FLOOR( RAND( ) * ( SELECT MAX( id ) FROM tablename ) )
  3. ORDER BY id ASC
  4. LIMIT 1

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.