Re: Random PostreSQL
| From: | Robin Vickery | Date: | Wed, 02 Aug 2000 10:45:08 +0000 |
| Subject: | Re: Random PostreSQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9666@lists.php.net to get a copy of this message | ||
joe@jWebMedia.com writes:
> Anyone know of a simple way to select a random group of records from
> postgeSQL? Can't find anything in the manual that is of any help to me.
> Thanks,
>
> Joe
oidrand(oid, int) takes an oid and a probability factor and returns true
or false based on that probability.
oidsrand(int) seeds the random number generator.
The probability factor is a little odd, the actual probability of any
row being selected is 1/factor.
SELECT * FROM mytable WHERE oidrand(oid, 10);
Would select approx 1/10 of the rows in the table.
-robin
--
Robin Vickery...............................................
Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
Email: robin@planet-three.net Phone: +44 (0)794 670 6395