View Single Post
Old 21-09-2006, 11:29   #1 (permalink)
gray
i still want paying
 
gray's Avatar
 
Join Date: Oct 2003
Location: newcastle, uk
Posts: 4,836
mysql selecting random rows, but use priority levels

evening gents, im trying to get my sql to pull out a random row, but grab rows with a higher priority more often than lower priorty - but still show lower priority rows occasionally...

i was thinking this, but failed.

PHP Code:
// priority_level is a column with values 1-5, 5 being high priority
$getFile mysql_query("SELECT * FROM $table 
ORDER BY RAND(),priority_level DESC LIMIT 1"
); 

can it be done?
  Reply With Quote