on-internet
← Community

$Lookup and $addField in mongodb

Stack Overflow ·

I have the following two collections and I want to be able to join them and output the number total number of games played by player A and player B. profiles collection [ { name: 'A' player_id: 1 }, { name: 'B' player_id: 2 } { name: 'C' player_id: 3 } ] games collection [ { game_id: 1 player_id: 1 }, { name: 2 player_id: 2 }, { game_id: 3 player_id: 1 }, { name: 4 player_id: 2 } { name: 5 player_id: 3 } ] Now the goal is the output the total number of games played by player A and B but not C when I am given their names but not ID. So the following SQL Statement: SELECT * FROM (results for A)

Comments

Sign in or sign up to comment and upvote.

No comments yet.