fenway Posted February 6, 2007 Share Posted February 6, 2007 Sorry, shoz, you're correct -- I didn't see the 'index' type, and even though all rows are "examined", the limit clause will deal with that. So, for all intents & purposes, the following query works as well: SELECT * FROM city WHERE idn >= FLOOR( ( SELECT MAX( idn ) FROM city ) * RAND() ) ORDER BY idn ASC LIMIT 1 Well done everybody! Time to make a new sticky... Quote Link to comment https://forums.phpfreaks.com/topic/37282-returning-a-random-row/page/2/#findComment-178443 Share on other sites More sharing options...
shoz Posted February 6, 2007 Share Posted February 6, 2007 I've edited the sticky to give credit to jan/jan's page for the JOIN. You can reword it if you'd like of course. Quote Link to comment https://forums.phpfreaks.com/topic/37282-returning-a-random-row/page/2/#findComment-178464 Share on other sites More sharing options...
fenway Posted February 6, 2007 Share Posted February 6, 2007 I've just changed the link to point to a valid, cached version of the page. Thanks, I missed that one. Quote Link to comment https://forums.phpfreaks.com/topic/37282-returning-a-random-row/page/2/#findComment-178480 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.