This query enable me to get all the players given team id and when his physical state is equals to 2.
$qb = $this->createQueryBuilder('player')
->where('player.physicalState= 2')
->join('player.team', 'team')
->addSelect('team')
->where('team.id = :id')
->setParameter('id', $teamId);
return $qb->getQuery()->execute()
But the fact is that: i have also another table OLD_TEAM. And Player have a one to many relationship with TEAM and OLD_TEAM. So a player can be linked to a TEAM or an OLD_TEAM.
So i want to improve/complete my query to have something like
Search my players in the team with id x in the TEAM table. If this not exist, i want to search the same but in the OLD_TEAM table.
I do not know if this solution is the best solution to search that, don't hesitate to inform me if there exists some easier solution(s).
PS : OLD_TEAM and TEAM use the same sequence for the PK.
Thanks.