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