Trouble writing what I consider a complex query. I have 2 tables. A table called teams and a table called people. A team is comprised of 2 people, or 2 user_ids which join back to the people table and user_id. I would like a query to show the team member names together on a team. Example: select team_number, player1, player2 In the example the player1 and player2 are just a user_id that pulls the player name from the people table.
What have you tried so far? If I assume your teams table has 2 columns for the 2 people, then you are going to have to join to the people table twice, once for each team member. Something like: select teams.team_number, people1.name as player1, people2.name as player2 from teams as teams join people as people1 on teams.user_id1 = people1.user_id --this first join is for one of the people join people as people2 on teams.user_id2 = people2.user_id --this second join is for the other