gpt4 book ai didi

mysql - Symfony2 查询语法错误

转载 作者:行者123 更新时间:2023-11-29 21:14:51 25 4
gpt4 key购买 nike

您好,我有以下联接查询。

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 ','.

我无法找出上述查询中缺少的内容。

最佳答案

问题出在这一行:

"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,
...

关于mysql - Symfony2 查询语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36034147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com