Page 1 of 1

Randomy mySQL picker

Posted: Tue Jul 26, 2005 10:03 am
by bla5e
How do I make a code that will RANDOMLY pick a user from a mySQL database?
Im using my forums `users` table for the database to be randomly picked from becuase im holding a competition for when I reach 100 members, I will be giving away money. Well I want PHP to randomly pick the member when I run the script but I have no idea where to start, please help with either an Idea or a code.

Thanks!

Posted: Tue Jul 26, 2005 10:07 am
by josh
SELECT * FROM `users` ORDER BY rand() LIMIT 1 ;

Posted: Tue Jul 26, 2005 10:08 am
by bla5e
oh, i didnt know there was a mysql query for it :oops:
thanks

Posted: Tue Jul 26, 2005 11:26 am
by Ambush Commander
The MySQL documentation can do wonders...

Here's the search: http://dev.mysql.com/doc/mysql/search.p ... nd&lang=en

Related section (found from search): http://dev.mysql.com/doc/mysql/en/mathe ... tions.html

It's in there.