Answer the question
In order to leave comments, you need to log in
Doctrine why doesn't dql work, what am I doing wrong?
$query = $entityManager->createQuery(
'SELECT MAX(employee.salary) FROM
AppBundle:Employee employee
JOIN AppBundle:Department department
WHERE department.id = :id'
)->setParameter('id', $department->getId());
$result = $query->getSingleScalarResult();
Answer the question
In order to leave comments, you need to log in
You're asking incorrectly. It should look something like this (I assume you have a @ManyToOne relationship configured between Employee and Department):
SELECT MAX(employee.salary)
FROM AppBundle:Employee employee
JOIN employee.department department
WHERE department.id = :id
SELECT MAX(employee.salary)
FROM AppBundle:Employee employee
WHERE IDENTITY(employee.department) = :id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question