Re: MySQL select rand() with weighting?

From: Date: Thu, 03 May 2001 19:25:30 +0000
Subject: Re: MySQL select rand() with weighting?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51311@lists.php.net to get a copy of this message
On Thu, 3 May 2001 20:15:26 +0100, James, Yz (liljim@btconnect.com) wrote: >Hi Guys, > >Does anyone know how to select one field randomnly from a MySQL table >against a weighting column in the same row the field is selected >from? > >For example, "SELECT id, url, image FROM table ORDER BY rand() LIMIT >1"..... i guess you'd just go ' order by rand()*weighting' - Mark >And have a column like "weighting" where values between 1 and 100 >are held - >The larger values making it more likely that they're going to get >pulled >out. So say I have three rows in the table, one "weighing" 100, the >others >weighing 50, the one weighhing 100 stands a better chance of being >selected >randomnly? > >I know I've not explained this too well, but hopefully *someone* >will know >what I'm rambling on about ;) > >Thanks as always, > >James. > > > >-- >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 (#51311) next »