MySQL select rand() with weighting?

From: Date: Thu, 03 May 2001 19:15:26 +0000
Subject: MySQL select rand() with weighting?
Groups: php.general 
Request: Send a blank email to php-general+get-51309@lists.php.net to get a copy of this message
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"..... 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.

« previous php.general (#51309) next »