Re: selecting records on a random basis with mysql function rand possible?

From: Date: Tue, 07 May 2002 13:29:24 +0000
Subject: Re: selecting records on a random basis with mysql function rand possible?
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-19011@lists.php.net to get a copy of this message
cool! works. thanx, Andy "Jason Wong" <phplist@gremlins.com.hk> schrieb im Newsbeitrag news:php.db-19009@news.php.net... > On Tuesday 07 May 2002 20:52, andy wrote: > > Hi there, > > > > is it possible to get mysql to return a record out of a table on a random > > basis? > > > > I tryed: > > > > select rand() ID, city > > from data.cities > > where country = 'CA' > > LIMIT 1 > > > > but does not work though. Has anybody an idea? I tryed also to read all > > results and do the random thing with php, but this does take forever (doing > > it for a couple of times) > > Try (won't work on older versions of mysql) > > SELECT something, or_another FROM table ORDER BY RAND() LIMIT 1; > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > > /* > You knew the job was dangerous when you took it, Fred. > -- Superchicken > */

« previous php.db (#19011) next »