Re: random record mysql

From: Date: Fri, 25 Apr 2003 00:45:25 +0000
Subject: Re: random record mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145211@lists.php.net to get a copy of this message
assuming rand() returns a random number you could do: select c1, c2 from table1 order by rand() limit 1; that should give you a random record every time at the cost of quite a bit of overhead (since it has to sort the whole table) On Thu, 24 Apr 2003, tbo wrote: > For the life of me I cannot figure out how to get a random record to be > displayed off a record set using mysql and php. I have seen examples of the > rand() function but it only brings up the first record in the record set. > Any ideas or tutorials? Please help!!!! :) > > -- > Tim Haskins > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#145211) next »