Re: random rows using MySQL's rand()
| From: | Justin French | Date: | Tue, 22 Oct 2002 02:45:00 +0000 |
| Subject: | Re: random rows using MySQL's rand() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120846@lists.php.net to get a copy of this message | ||
You really should be asking this on a MySQL list.
Justin
on 22/10/02 10:54 AM, Tanat (PHP@Tanat.Net) wrote:
> Hi all,
>
> I was trying to use the following query to randomly retrieve a row from
> MySQL table.
>
> $query = "SELECT * FROM my_table ORDER BY RAND() LIMIT 1";
>
> This query works fine in MySQL client, access via command-line.
>
> But when using this via PHP, it doesn't retrieve the row randomly for a
> small set of records, ie. 3.
> Now that I've increased the number of records to 32, it starts to show
> random behaviour.
>
> So, just wondering whether this is something I can expect for a table with
> only a few records.
>
> Regards,
> Tanat
>
>