Try this instead... SELECT val_column, 0.1+RAND() as rand_col from TABLE ORDER BY rand_col limit 10;
Cheers, A -----Original Message----- From: Eric Wagner [mailto:[EMAIL PROTECTED] Sent: Tuesday 10 June 2003 21:36 To: Dathan Vance Pattishall; [EMAIL PROTECTED] Subject: RE: Hmm looks like this query works I think your query will just return the first 10 values in the table sorted in random order due to how MySQL handles queries that use ORDER BY and LIMIT: [from mysql documentation] If you use LIMIT # with ORDER BY, MySQL will end the sorting as soon as it has found the first # lines instead of sorting the whole table http://www.mysql.com/doc/en/LIMIT_optimisation.html > -----Original Message----- > From: Dathan Vance Pattishall [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 10, 2003 11:19 AM > To: [EMAIL PROTECTED] > Subject: Hmm looks like this query works > > > I have a question. If I wanted to sort randomly on a column weighted > by the value of the column will does this query work > > SELECT val_column, val_column*0.1+RAND() as rand_col from TABLE ORDER > BY rand_col limit 10; > > This should five me a random row weighted by the value of the column > is this correct? Seems to be but I might be wrong. > > Thanks for any tips > > -- > Dathan -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]