apollo2020 Posted September 20, 2009 Share Posted September 20, 2009 I have a database indexing videos. I want to collect 10 videos randomly but only from the last 100 videos recently added. What's the sql string I should use for this? MySql fields are: $videoid $date_added // For example, ? is what I need unless the select statement is also altered mysql_query("SELECT * FROM videos WHERE ? "); Quote Link to comment https://forums.phpfreaks.com/topic/174870-how-to-get-10-videos-from-last-100-videos-randomly/ Share on other sites More sharing options...
khr2003 Posted September 20, 2009 Share Posted September 20, 2009 try this mysql_query("SELECT * FROM videos rand() ASC LIMIT 0,100 "); Quote Link to comment https://forums.phpfreaks.com/topic/174870-how-to-get-10-videos-from-last-100-videos-randomly/#findComment-921611 Share on other sites More sharing options...
fenway Posted September 21, 2009 Share Posted September 21, 2009 You'll need to use ORDER BY and LIMIT 100, and then run that in a sub-select for RAND(). Quote Link to comment https://forums.phpfreaks.com/topic/174870-how-to-get-10-videos-from-last-100-videos-randomly/#findComment-922579 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.