I am facing difficulties to join three tables. And then joining the third table two times to get user information
I have a table called teams and in this table, I have playerOneId and playerTwoId. These id s are actually from users table so I also want to get both the players information from the users table. So here I tried a query
select
`clubteams`.`id`, `clubteams`.`className`, `clubteams`.`que`,
`teams`.`id`, `teams`.`teamName`, `teams`.`playerOneId`, `teams`.`playerTwoId`,
`users`.`firstName`, `users`.`lastName`, `users`.`email`, `users`.`phone`
from `teams`
inner join `clubteams` on `teams`.`id` = `clubteams`.`team_id`
inner join `users` on `teams`.`playerOneId` = `users`.`id`
inner join `users` on `teams`.`playerTwoId` = `users`.`id`
where `clubteams`.`club_id` = 9 and `clubteams`.`isTemporary` = 1
Here note that two joins with users table
inner join `users` on `teams`.`playerOneId` = `users`.`id`
inner join `users` on `teams`.`playerTwoId` = `users`.`id`
how can I get both players information using playerOneId and playerTwoId?