Select a random row (like user or post) from your MySQL table

I have beein using all kinds of strange constructs to be able to select a random row (often user or post) from table, and then I stubled over this on sitepoint forums:

SELECT * FROM users WHERE age > 20 ORDER BY RAND() LIMIT1

One simple argument to the query! Awsome. Hope it helps you as much as it helped me.

Popularity: 10% [?]

No Comments Posted in MySQL

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>