MySQL ORDER BY RANDOM... How?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

MySQL ORDER BY RANDOM... How?

Post by JellyFish »

I'm trying to select data from the database and I'd like to order it by random. How must I do this?

Thanks and all help is appreciated.
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

select * from table order by rand()

http://www.greggdev.com/web/articles.php?id=6
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This was just asked.

viewtopic.php?t=45177
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Okay works perfect, thanks wtf. :) And thanks feyd for your reply, I guess I should allways check if there's allready a post on a topic I'm going to post. :)
Post Reply