Jump to content

Returning a random row


teerock

Recommended Posts

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.