AlphaShade Posted July 25, 2006 Share Posted July 25, 2006 Hello!Well basically I have a problem.I have a table with a value: Popularity. What I want to do is do a site randomization. I have rows: id, url, website_description, popularityWhat I want to do is do a randomization where a site will come up in the script by a popularity number of 1 to 100(or more).My problem is I have seen plenty of randomization scripts out there but nothing this complex.Wondering if someone knows a way to do this. I want it to randomize all sites but those sites that have the highest popularity rating would show up more then the sites with the lowest.Any help you can give me would be great!Thanks for reading :) Quote Link to comment Share on other sites More sharing options...
fenway Posted July 25, 2006 Share Posted July 25, 2006 Complex? Sounds like you want to pull N random records from your table, and then sort by the popularity field. What's the problem? Quote Link to comment Share on other sites More sharing options...
AlphaShade Posted July 26, 2006 Author Share Posted July 26, 2006 [quote author=fenway link=topic=101835.msg403484#msg403484 date=1153866735]Complex? Sounds like you want to pull N random records from your table, and then sort by the popularity field. What's the problem?[/quote]Complex to me because I do not know how to do that. And problem is I am such a newbie that I do not know how I would do it. Thus my reason for asking if someone knew. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 26, 2006 Share Posted July 26, 2006 Assuming you're using 4.1+, you can accomplish this with a sub-query:[code]SELECT id, url, website_description, popularity FROM yourTable WHERE id IN ( SELECT id FROM yourTable ORDER BY RAND() LIMIT 5 ) ORDER BY popularity DESC[/code]I didn't mean that you're question wasn't valid, just that the problem were you describing wasn't complex. Quote Link to comment Share on other sites More sharing options...
AlphaShade Posted July 26, 2006 Author Share Posted July 26, 2006 Thanks, Oh I didnt understand what you meant by whats the problem :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.