您好我有以下加入查询。
return $this->getEntityManager()
->createQuery(
"SELECT t1.taskId,t1.title,t1.dueDate,t1.modified,cb.forename,cb.surname,up.profilePhotoPath,
(SELECT tp.metaData,tp.content FROM AppBundle:J1TaskPost tp order by tp.created DESC ) AS taskPost
FROM AppBundle:J1Task as t1
JOIN t1.assignees As ta
JOIN t1.createdBy As cb
JOIN AppBundle:J1UserProfile as up WITH t1.createdBy = up.user
WHERE t1.deleted IS NULL and t1.status = false and ta.userid=$userId group by t1.taskId order by tp.created desc"
)->getResult();
抛出以下错误:
Syntax Error] line 0, col 130: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got ','.
我无法找出上述查询中缺少的内容。
答案 0 :(得分:0)
问题出在这一行:
"SELECT t1.taskId,t1.title,t1.dueDate,t1.modified,cb.forename,cb.surname,up.profilePhotoPath,
(SELECT tp.metaData,tp.content FROM AppBundle:J1TaskPost tp order by tp.created DESC ) AS taskPost
您需要选择taskPost中的项目,但您在此处所做的是定义表格。你能做的是:
SELECT t1.taskId,t1.title,t1.dueDate,t1.modified,cb.forename,cb.surname,up.profilePhotoPath, taskPost.metaData, taskPost.content FROM
(SELECT tp.metaData,tp.content FROM AppBundle:J1TaskPost tp order by tp.created DESC ) AS taskPost,
...