* [EMAIL PROTECTED]
> In Re: Selecting records with the highest value no greater than
> x, <[EMAIL PROTECTED]> wrote:
> >
> >IMO, there is one, if I did understand the question correctly:
> >
> >SELECT * FROM NEWS WHERE RATING <= 4 ORDER BY RATING DESC,
> > RAND() LIMIT 1;
> >
> >This give back a random news entry of the highest score available, but
> >smaller than 5.
>
>
> It just gives back a random news story, as it is logically identical to
>
> SELECT * FROM NEWS WHERE RATING <= 4 ORDER BY RAND() LIMIT 1;

No, it's not. The former will sort on the rating first, and then do a random
sort within each rating group.

> You would need a 'non-uniform' random function for your version to work.

I don't understand why you say this. Benjamin's ORDER BY clause will select
a random row among those having the highest rating lower or equal to four,
just as one would expect from the statement.

--
Roger
query


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to