Answer the question
In order to leave comments, you need to log in
How to make multiple Join to same table symfony, querybuilder?
There is a command table:
command_id | team_name
There is a match table:
match_number | home_team_id | id_guest_team
id teams in the "match" table are equal to id teams from the "team" table
In symfony3 using querybuilder I make a selection
$match= $this->getDoctrine()->getEntityManager()
->createQueryBuilder()
->select ('p.idMatch, pp.name, dp.name')
->from('match', 'p')
->innerJoin('AppBundle:teams', 'pp', 'with', "p.hometeam = pp.teamId")
->innerJoin('AppBundle:teams', 'dp', 'with', "p.awayteam = dp.teamId")
->getQuery()
->getResult();
SELECT
g.*,
t1.name AS home_team_name,
t2.name AS guest_team_name
FROM
game AS g
INNER JOIN team AS t1 ON g.home_team_id = t1.id
INNER JOIN team AS t2 ON g.guest_team_id = t2.id;
ORDER by game_date DESC
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question