List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:September 17 1999 6:01pm
Subject:Re: SELECT Random sets possible?
View as plain text  
David Fallon wrote:
> 
> Is it possible to SELECT a random recordset out of a database? If so, what's
> the syntax? (I want to get a random selection of 5 items from a table).
> 
> I'm not subscribed to the list, so please reply directly to me.

Hi David

I've not tested this myself.
You have to use 3.23.3 for this to work (which I currently don't use):
SELECT * FROM table ORDER BY RND() LIMIT 5;

Or you can add a column and fill it randomly to sort after this (works with 3.22.xx
versions):
ALTER TABLE table ADD random DOUBLE;
UPDATE table SET random=RND();
SELECT * FROM table ORDER BY random LIMIT 5;

Tschau
Christian

Thread
SELECT Random sets possible?David Fallon16 Sep
  • Re: SELECT Random sets possible?Christian Mack17 Sep
    • Re: SELECT Random sets possible?Michael Widenius18 Sep
      • Re: SELECT Random sets possible?Martin Ramsch18 Sep
        • Re: SELECT Random sets possible?Michael Widenius19 Sep