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 ? "); 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 "); 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(). 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
Archived
This topic is now archived and is closed to further replies.