RE: [PHP] random rows using MySQL's rand()

From: Date: Tue, 22 Oct 2002 02:54:51 +0000
Subject: RE: [PHP] random rows using MySQL's rand()
Groups: php.general 
Request: Send a blank email to php-general+get-120849@lists.php.net to get a copy of this message
or at least the PHP - Database list (php-db@lists.php.net) ... but anyways ... I am also using that exact code also: mysql_query('SELECT * FROM quotes ORDER BY RAND() LIMIT 1'); with 'quotes' a table ~300 rows and it works fine. I have seen it go roughly through every quote in the table over the last year. -Peter > -----Original Message----- > From: Justin French [mailto:justin@indent.com.au] > Sent: Tuesday, October 22, 2002 04:45 > To: Tanat; php-general@lists.php.net > Subject: Re: [PHP] random rows using MySQL's rand() > > > 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 > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#120849) next »