Jump to content

Mysql MAX()


wongerlt

Recommended Posts

Hi all.

I have query

SELECT name,game,score, MAX(score) FROM `servers` WHERE `on`='2' group BY `game` DESC

but it bad ;/

I need:

Example:

id - name - game - score

1 - test - 45 - 78

2. - iks - 13 - 43

3. - lips - 45 - 15

4. - cat - 45 - 74

5. - dog - 13 - 56

...

and i need query a mains so:

1.test 78

2.dog 56

 

one rezult from one game with max score.

 

Soz for bad english.

Link to comment
https://forums.phpfreaks.com/topic/239543-mysql-max/
Share on other sites

Thx.

But what here wrong:

SELECT ids, game, score
FROM   shop s1
WHERE  score=(SELECT MAX(s2.score)
              FROM shop s2
              WHERE s1.ids = s2.ids) GROUP BY `game`;

table:

ids.      game    score

4568 12 2056

4646 12 3

454564 13 75

8778 13 16

46487 13 1

4541 24 56

13131 24 87

6464 24 185

 

i get result:

ids.    game.  score.

4541 24 56

454564 13 75

4568 12 2056

 

but should be:

ids.      game.  score.

4568 12 2056

454564 13 75

6464 24 185

 

why last result is bad?

Link to comment
https://forums.phpfreaks.com/topic/239543-mysql-max/#findComment-1230545
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.