RE: [PHP] Random PostreSQL

From: Date: Tue, 01 Aug 2000 21:00:59 +0000
Subject: RE: [PHP] Random PostreSQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-9553@lists.php.net to get a copy of this message
A couple of ideas, but it really depends on how many you want: - If you had an autonumber key you could fill an array with random numbers and then select those records. - Pick a random start record and use LIMIT to select the number of records you want from that point. You could make this more random by picking a different column to ORDER BY each time. > -----Original Message----- > From: Christensen, BruceX R [mailto:brucex.r.christensen@intel.com] > Sent: Tuesday, August 01, 2000 1:31 PM > To: 'joe@jWebMedia.com'; PHP mailing list (E-mail) > Subject: RE: [PHP] Random PostreSQL > > > I really doubt that's possible. If the table's small enough, you > could just > grab all of the rows in your SELECT query, but only actually use some of > them. If it's very large (but each row has a sequential number, > such as an > auto-incrementing primary key [in which case it's important that > no records > have been deleted from the middle of the series of primary > keys]), you could > find out how many rows there are in the table, then do something > like SELECT > * FROM table WHERE id=rand1 OR id=rand2, etc, where rand1 and rand2 are > random numbers you've generated that are between the lowest and highest > primary key. > > --Bruce > > Bruce Christensen > Intel Corporation > brucex.r.christensen@intel.com > > > -----Original Message----- > From: joe@jWebMedia.com [mailto:joe@jWebMedia.com] > Sent: Tuesday, August 01, 2000 1:26 PM > To: php-general@lists.php.net > Subject: [PHP] Random PostreSQL > > > 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 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#9553) next »