Bold dream
Imagination is limitless. So is stupidity.
Now viewing all posts in Python

Getting a random row from a relational database

January 22nd 2010

Problem From time to time one needs to fetch a random row from a table in a db. Solution Take one The “obvious” solution is to order by RAND() and get the first: SELECT * FROM users ORDER BY RAND() LIMIT 1; /* Don’t do that */ It does the job, problem solved! Well, no, [...]

Read On 9 Comments


Blogroll