dbTalk Databases Forums  

get me all players and get me even the last team in which he plays

comp.databases.mysql comp.databases.mysql


Discuss get me all players and get me even the last team in which he plays in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mariano C.
 
Posts: n/a

Default get me all players and get me even the last team in which he plays - 04-02-2011 , 05:53 AM






I've this select.

SELECT `Carrier`.`player_id`, `Carrier`.`team_id`,
`Carrier`.`created`
FROM `carriers` AS `Carrier`
ORDER BY `Carrier`.`team_id` ASC , `Carrier`.`player_id` ASC

that produce this output:

Player1 Team1 2011-04-02 10:02:59
Player2 Team1 2011-04-02 10:01:10
Player1 Team2 2011-04-02 10:05:26
Player2 Team2 2011-04-02 09:45:27

Now I need just the player's last team, so query should product
something like "for every Player get me the team with max
Carrier.created":

Player2 Team1 2011-04-02 10:01:10
Player1 Team2 2011-04-02 10:05:26

How can I rewrite the former query?

Reply With Quote
  #2  
Old   
Helmut Chang
 
Posts: n/a

Default Re: get me all players and get me even the last team in which heplays - 04-02-2011 , 09:20 AM






Am 02.04.2011 12:53, schrieb Mariano C.:
Quote:
I've this select.

SELECT `Carrier`.`player_id`, `Carrier`.`team_id`,
`Carrier`.`created`
FROM `carriers` AS `Carrier`
ORDER BY `Carrier`.`team_id` ASC , `Carrier`.`player_id` ASC

that produce this output:

Player1 Team1 2011-04-02 10:02:59
Player2 Team1 2011-04-02 10:01:10
Player1 Team2 2011-04-02 10:05:26
Player2 Team2 2011-04-02 09:45:27

Now I need just the player's last team, so query should product
something like "for every Player get me the team with max
Carrier.created":

Player2 Team1 2011-04-02 10:01:10
Player1 Team2 2011-04-02 10:05:26

How can I rewrite the former query?
<http://dev.mysql.com/doc/refman/5.1/en/example-maximum-column-group-row.html>

HTH, Helmut

Reply With Quote
  #3  
Old   
Mariano C.
 
Posts: n/a

Default Re: get me all players and get me even the last team in which he plays - 04-02-2011 , 10:10 AM



On 2 Apr, 16:20, Helmut Chang <use... (AT) helmutchang (DOT) at> wrote:
Quote:
Am 02.04.2011 12:53, schrieb Mariano C.:









I've this select.

SELECT *`Carrier`.`player_id`, `Carrier`.`team_id`,
`Carrier`.`created`
FROM *`carriers` AS *`Carrier`
ORDER BY *`Carrier`.`team_id` ASC , *`Carrier`.`player_id` ASC

that produce this output:

Player1 * *Team1 * 2011-04-02 10:02:59
Player2 * *Team1 * 2011-04-02 10:01:10
Player1 * *Team2 * 2011-04-02 10:05:26
Player2 * *Team2 * 2011-04-02 09:45:27

Now I need just the player's last team, so query should product
something like "for every Player get me the team with max
Carrier.created":

Player2 * *Team1 * 2011-04-02 10:01:10
Player1 * *Team2 * 2011-04-02 10:05:26

How can I rewrite the former query?

http://dev.mysql.com/doc/refman/5.1/...column-group-r...

HTH, Helmut
Thank you

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.