我有我的分数表,其中有 1 个用户的多个分数。我要做的是为每个用户选择所有最高分。
我正在尝试在 Doctrine DQL 中进行休闲:
SELECT * FROM scores s1
LEFT OUTER JOIN scores s2 ON
s1.user_id = s2.user_id
AND ((s1.score < s2.score) OR (s1.score = s2.score AND s1.date_added < s2.date_added))
WHERE s2.score IS NULL
ORDER BY s1.score DESC
LIMIT 10
我现在的状态是:
$rowQuery = $this->getEntityManager()->createQuery('
SELECT s1 FROM \Digital\ApplicationBundle\Entity\ChallengeScore s1
LEFT OUTER JOIN \Digital\ApplicationBundle\Entity\ChallengeScore s2
ON (
s1.user = s2.user
AND
(s1.score < s2.score OR (s1.score = s2.score AND s1.date_added < s2.date_added))
)
WHERE s2.score IS NULL
AND s1.date_added BETWEEN :monday AND :sunday
ORDER BY s1.score DESC
');
$rowQuery->setParameter('monday', $startDate->format('Y-m-d'))
->setParameter('sunday', $endDate->format('Y-m-d'));
$rowQuery->setMaxResults($limit);
return $rowQuery->getResult();
我收到以下错误:
[Syntax Error] line 0, col 188: Error: Expected Literal, got '�'
我究竟做错了什么?