tags:

views:

46

answers:

1

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?

+3  A: 

Try this:

SELECT * FROM tableName ORDER BY RAND() LIMIT 1
Delan Azabani
This will not perform well for large number of records.
Unreason