select question

This is a discussion on select question within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I have a mysql database which holds a list of scores. I would like to find the minimum score ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-07-2007
Paul
 
Posts: n/a
Default select question

Hi,

I have a mysql database which holds a list of scores. I would like to
find the minimum score in the list and then get the detail of that
score. I've used:-

select MIN(score) from highscores;

this gives me 150.

select * from highscores where score = 150;

then I can get the detail. Is there a way to combine this with one call?
Something like:-

select * from highscores where MIN(score);

BTW, what happens if there are more than one minimum score?

(Basically, I have flash game and want to create a high score list. So I
suppose we'd have to find the minimum score in the db and if that is
smaller than the current game score add it to the db else forget it.)

Any help appreciated.

Paul

Reply With Quote
  #2 (permalink)  
Old 03-07-2007
Sean
 
Posts: n/a
Default Re: select question

This should return all rows with the a score equal to the minimum.

SELECT *
FROM HIGHSCORES
WHERE SCORE IN
(
SELECT MIN(SCORE)
FROM HIGHSCORES
)

Sean




"Paul" <paulfredlein@NOSPAMoptusnet.com.au> wrote in message
news:1hum0ak.1j8yw2ucf7tm0N%paulfredlein@NOSPAMopt usnet.com.au...
> Hi,
>
> I have a mysql database which holds a list of scores. I would like to
> find the minimum score in the list and then get the detail of that
> score. I've used:-
>
> select MIN(score) from highscores;
>
> this gives me 150.
>
> select * from highscores where score = 150;
>
> then I can get the detail. Is there a way to combine this with one call?
> Something like:-
>
> select * from highscores where MIN(score);
>
> BTW, what happens if there are more than one minimum score?
>
> (Basically, I have flash game and want to create a high score list. So I
> suppose we'd have to find the minimum score in the db and if that is
> smaller than the current game score add it to the db else forget it.)
>
> Any help appreciated.
>
> Paul
>




Reply With Quote
  #3 (permalink)  
Old 03-07-2007
Kurt
 
Posts: n/a
Default Re: select question

paulfredlein@NOSPAMoptusnet.com.au (Paul) wrote in
news:1hum0ak.1j8yw2ucf7tm0N%paulfredlein@NOSPAMopt usnet.com.au:

> Hi,
>
> I have a mysql database which holds a list of scores. I would like to
> find the minimum score in the list and then get the detail of that
> score. I've used:-
>
> select MIN(score) from highscores;
>
> this gives me 150.
>
> select * from highscores where score = 150;
>
> then I can get the detail. Is there a way to combine this with one call?
> Something like:-
>
> select * from highscores where MIN(score);
>
> BTW, what happens if there are more than one minimum score?
>
> (Basically, I have flash game and want to create a high score list. So I
> suppose we'd have to find the minimum score in the db and if that is
> smaller than the current game score add it to the db else forget it.)
>
> Any help appreciated.
>
> Paul
>


Maybe...

select * from highscores order by score desc limit 1;

or
select * from highscores where score = (select MIN(score) from highscores);


Kurt
--
NNTPjunkie.com Usenet
30 GB $9.95 monthly

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:20 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0