Re: selecting a random record
От | Arun Malhotra - Roll No.99007 |
---|---|
Тема | Re: selecting a random record |
Дата | |
Msg-id | Pine.LNX.4.21.0102111429160.12835-100000@gdit.iiit.net обсуждение исходный текст |
Ответ на | selecting a random record (Culley Harrelson <culleyharrelson@yahoo.com>) |
Список | pgsql-general |
Hi I dont know exactly why u need this but this can be done in MySQL/PERL create a file called random.pl i select a random reecord from Temp table with PK temp_id #! /usr/bin/perl -w use Mysql; $i = (10*rand())%10; $dbh = Mysql->Connect('localhost','DBNAME','root'); $sth = $dbh->Query("Select * from Temp"); $no = $dbh->Query("Select COUNT(temp_id) from Temp"); @nr = $sth->FetchRow; for($n=0; $n<@nr[0]; $n++) { @row = $sth->FetchRow; if($n == $i) { print @row; } } On Tue, 6 Feb 2001, Culley Harrelson wrote: > Any suggestions on how to select a random record from > any given table? > > Culley > > __________________________________________________ > Do You Yahoo!? > Yahoo! Auctions - Buy the things you want at great prices. > http://auctions.yahoo.com/ >
В списке pgsql-general по дате отправления: