Jump to content

fnsweet

New Members
  • Posts

    2
  • Joined

  • Last visited

fnsweet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. the vital_id is an auto incro, the max number would be the latest entry for that player. i believe that i have to use group-wise maximum but i cant get it to work correctly
  2. Hello everyone, I am hopping someone can help me sort out a query. I have two tables, one table is a players table, and a second table is a player_vitals data that stores heights and weight changes. I want to list all the players showing the latest height and weight change. this query will not fetch the latest height and weight SELECT a.player_id, a.player_first_name,a.player_last_name, b.player_height, b.player_weight FROM players a LEFT JOIN (SELECT vital_id, player_id, player_height, player_weight FROM player_vitals ORDER BY vital_id DESC LIMIT 1) b ON b.player_id = a.player_id LEFT JOIN teams c using (team_id) ORDER BY player_last_name, player_first_name this query will work only if i tell it what player_id to select from SELECT a.player_id, a.player_first_name,a.player_last_name, b.player_height, b.player_weight FROM players a LEFT JOIN (SELECT vital_id, player_id, player_height, player_weight FROM player_vitals WHERE player_id = 6 ORDER BY vital_id DESC LIMIT 1) b ON b.player_id = a.player_id LEFT JOIN teams c using (team_id) where a.player_id = 6 ORDER BY player_last_name, player_first_name but i need I need to get my first query to work listing all players, am i missing something? Thanks
×
×
  • 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.