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% [?]

Comments are closed.