ERuiz Posted October 28, 2007 Share Posted October 28, 2007 Let say I have a mysql query, which might yield more than 1 row when queried. How can I set up the query, so that it RANDOMLY selects one of the results? I know that I can do a LIMIT 1 command, but this will always yield the first row. Thanks for any guidance... ERuiz Link to comment https://forums.phpfreaks.com/topic/75066-solved-selecting-a-random-row-of-a-mysql-query-result/ Share on other sites More sharing options...
Zane Posted October 28, 2007 Share Posted October 28, 2007 SELECT what FROM table ORDER BY RAND() LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/75066-solved-selecting-a-random-row-of-a-mysql-query-result/#findComment-379660 Share on other sites More sharing options...
ERuiz Posted October 28, 2007 Author Share Posted October 28, 2007 SELECT what FROM table ORDER BY RAND() LIMIT 1 You gotta be kidding me, you serious? That simple? THANKS! Link to comment https://forums.phpfreaks.com/topic/75066-solved-selecting-a-random-row-of-a-mysql-query-result/#findComment-379661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.