Re: Selecting records with the highest value no greater than x

2002-02-17 Thread Anvar Hussain K.M.
Hi Benjamin, The perfect answer. Thank you, Anvar. At 08:44 AM 16/02/2002 +0100, you wrote: >Hi. > >On Fri, Feb 15, 2002 at 09:05:02PM -0800, [EMAIL PROTECTED] wrote: > > In Re: Selecting records with the highest value no greater than x, > <[EMAIL PROTECTED]> wr

RE: Selecting records with the highest value no greater than x

2002-02-16 Thread Roger Baklund
* [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, >

Re: Selecting records with the highest value no greater than x

2002-02-16 Thread MySQL
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

Re: Selecting records with the highest value no greater than x

2002-02-15 Thread Benjamin Pflugmann
Hi. On Fri, Feb 15, 2002 at 09:05:02PM -0800, [EMAIL PROTECTED] wrote: > In Re: Selecting records with the highest value no greater than x, ><[EMAIL PROTECTED]> wrote: > > > >Hi Brent, > > > >I cannot think of a single query doing your job. IMO, there is o

Re: Selecting records with the highest value no greater than x

2002-02-15 Thread MySQL
In Re: Selecting records with the highest value no greater than x, <[EMAIL PROTECTED]> wrote: > >Hi Brent, > >I cannot think of a single query doing your job. But it can be done >with two. > >SELECT @maxrating := MAX(RATING) FROM NEWS WHERE RATING <= 4; &g

Re: Selecting records with the highest value no greater than x

2002-02-15 Thread Anvar Hussain K.M.
Hi Brent, I cannot think of a single query doing your job. But it can be done with two. SELECT @maxrating := MAX(RATING) FROM NEWS WHERE RATING <= 4; SELECT * FROM NEWS WHERE RATING=@maxrating ORDER BY RAND() LIMIT 1; Anvar. At 02:36 PM 15/02/2002 -0700, you wrote: I need some help here. Let'

Re: Selecting records with the highest value no greater than x

2002-02-15 Thread Michael Stassen
How about SELECT * FROM news WHERE rating <= 4 ORDER BY rating DESC, RAND() LIMIT 1; Michael On Fri, 15 Feb 2002, Brent Macnaughton wrote: > > I need some help here. Let's see if I can clearly describe it. > > I have a database containing "news" stories. Each story is assigned a > "r

Selecting records with the highest value no greater than x

2002-02-15 Thread Brent Macnaughton
I need some help here. Let's see if I can clearly describe it. I have a database containing "news" stories. Each story is assigned a "rating" (1 thru 5) indicating its importance. (A story with a rating of 5 is more important than a story with rating of 1.) Now, lets say that there are ten s