Earlier on, I thought I could use rand () as follows:

SELECT rand () FROM Products LIMIT 2;
_____________
0.2036000.....
0.125689......
____________

2 rows

Your suggestion worked ok.

Thanks Alex


----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 29. März 2004 14:59
An: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] Mysql. Com
Betreff: Re: Selecting rows at random


"B. Fongo" <[EMAIL PROTECTED]> wrote on 29/03/2004 13:54:54:

> Does MySQL provide a way of selecting a limited number of rows at
> random?  From a query that might return several rows, I want MySQL to
> return six rows at random at each time.
>
> For instance:
>
> Select * from [table] where [condition];
>
> 200 rows (0.0 sec)
>
>
> Now - I need 6 rows at random.

SELECT * FROM table ORDER BY rand() LIMIT 6 ;

      Alec



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to