On Fri, Jan 26, 2007 at 01:38:07PM -0500, Igor Tandetnik wrote: > Nicolas Williams <[EMAIL PROTECTED]> wrote: > >But I read that as "goto to offset 2 and return the first row after > >offset 2." > > Why offset 2, when the clause reads, say, OFFSET 500? Also, there are > just two rows, at offset 0 and offset 1. What do you mean by "return > first row after offset 2"? There are none.
Actually, a query that does that would be: SELECT rowid,* FROM foo WHERE rowid >= (abs(random()) % (SELECT rowid FROM foo ORDER BY rowid DESC LIMIT 1)) ORDER BY rowid ASC LIMIT 1; And yes, if the table is sparse then this will not necessarily select rows entirely randomly. Depending on the distribution of your rowids this may work well enough and be fast. Nico -- ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------