I am trying to match up data between two tables by using the same values from the main query in the sub-query. I am using 3 tables for this:
World - The area of the world that the player has been in Player - The actual player Objects destroyed - Just a stats table used to keep track of the player's progress in the world
What I am trying to do is to create a query that displays the play and the world they were in and get a count of all the objects they have destoryed in that world. My query is currently like this:
select
world_id,
world_name,
player_id
count(select * from objects_destoryed where player_id = <insert player ID>) as Stats
from
Worlds
join Players using (player_id)
where
player_id = <insert player ID>
What I am asking is if there is a better way rather then including the player ID twice to get the overall statistics. Also is there a way that I can expand this to run on multiple players that were in that world? Such as using a player_id in statement.
Thanks for any advice