Hi, i have the following table structure:
players:
- player_id (primary key)
- player_name
player_points:
- player_id
- points
- date_created (date record added)
The players to player_points tables have a 1 to many relationship. Therefore there can be multiple records in the player_points table with the same player_id. What i need to do is a query that gets all the players and their latest points score (based on the date_created)
So far i have:
but it returns every record from the player_points table.
Appreciate if someone could show me where i'm going wrong.
Thanks
players:
- player_id (primary key)
- player_name
player_points:
- player_id
- points
- date_created (date record added)
The players to player_points tables have a 1 to many relationship. Therefore there can be multiple records in the player_points table with the same player_id. What i need to do is a query that gets all the players and their latest points score (based on the date_created)
So far i have:
Code:
SELECT
`player_points`.`points`,
`players`.`player_name`
FROM
`player_points`
Left Outer Join `players` ON `player_points`.`player_id` = `players`.`player_id`
ORDER BY
`player_points`.`date_created` DESC
but it returns every record from the player_points table.
Appreciate if someone could show me where i'm going wrong.
Thanks