LanceT Posted January 14, 2007 Share Posted January 14, 2007 I want my script to get 5 randomly generated rows from my mySQL database. Is there a way to do this with a select statement? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 14, 2007 Share Posted January 14, 2007 Well, ORDER BY RAND() LIMIT 5 is the lazy way, and is very slow for very large tables... there are many other ways, but it depends on your table. Quote Link to comment Share on other sites More sharing options...
LanceT Posted January 14, 2007 Author Share Posted January 14, 2007 yeah the table is actually pretty large, is there a better way? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 15, 2007 Share Posted January 15, 2007 Well, if you only needed one row, it would be easier... especially if you absolutely need 5 every time. I can't remember the exact page, but there are some excellent discussions on alternatives. Quote Link to comment Share on other sites More sharing options...
LanceT Posted February 14, 2007 Author Share Posted February 14, 2007 I still need help on this. Anyone else? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 14, 2007 Share Posted February 14, 2007 I've posted a sticky... have you taken a look? 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.