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 Quote 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 Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.