How to select a random record from a MySQL database?

Posted by Bruce on Stack Overflow See other posts from Stack Overflow or by Bruce
Published on 2010-05-06T05:19:31Z Indexed on 2010/05/06 5:28 UTC
Read the original article Hit count: 198

Filed under:
|

I am using the following query to select 1 random record -

SELECT name FROM table WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM table ) ORDER BY id LIMIT 1

but it gives me the same set of records every time I call it. How do I get better random record?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql