createQueryBuilder('a'); //Selecting user info $qb->select('DISTINCT u'); // Loading EntityUser $qb->from('Entity\Jury', 'u'); // Selecting members $qb->innerJoin('u.members', 'c'); // Inner join with the table c_quiz_question_rel_category. $qb->innerJoin('c.role', 'r'); //@todo check app settings //$qb->add('orderBy', 'u.lastname ASC'); $wherePart = $qb->expr()->andx(); //Get only users subscribed to this course $wherePart->add($qb->expr()->eq('r.role', $qb->expr()->literal('ROLE_JURY_PRESIDENT'))); $wherePart->add($qb->expr()->eq('c.userId', $userId)); $qb->where($wherePart); $q = $qb->getQuery(); return $q->getSingleResult(); //return $qb; } public function getExerciseAttemptsByJury($juryId) { } }