FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Tips to select Random rows from mysql

 
Post new topic   Reply to topic    Cambodia eXPlore Forum Index -> General Webmaster
Author Message
guitarman
fourth grade


Joined: 04 Nov 2005
Posts: 728

PostPosted: Tue Jul 10, 2007 10:05 pm    Post subject: Tips to select Random rows from mysql Reply with quote

I was doing my small project after the central australia and one of the feature is to select photos randomly from MySQL table. And below is what I used to select random row:

Code:
"SELECT * FROM tableName order by rand() limit 10"

Note that the limit is 10 because I just wish to select 10 rows.

Hope that's helpful for someone with similar issue.
Cheers,
GuitarmAn

Back to top
indogo
fourth grade


Joined: 03 May 2006
Posts: 223

PostPosted: Wed Jul 11, 2007 4:22 am    Post subject: Reply with quote



Hmm that sound useful.....................

mike Very Happy

Back to top
Singachea
fourth grade


Joined: 19 Nov 2005
Posts: 258

PostPosted: Wed Jul 11, 2007 11:16 pm    Post subject: Reply with quote

indogo wrote:
Hmm that sound useful.....................

mike Very Happy


I agree

Back to top
mckz



Joined: 18 Jul 2007
Posts: 1

PostPosted: Wed Jul 18, 2007 4:43 pm    Post subject: Reply with quote

this is very slow if you have a lot of rows... know any other ways?

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cambodia eXPlore Forum Index -> General Webmaster All times are GMT + 8 Hours
Page 1 of 1



by phpBB