我刚从mysql切换到postgresql,我的工作dql查询停止工作。
这是我的dql
SELECT p
FROM AppBundle:Photo p
JOIN AppBundle:Like l WITH p = l.photo
WHERE p.isModerated = :isModerated
AND p.isActive = :isActive
AND p.category IN(:categories)
AND p.creationDate <= :begin
AND p.creationDate >= :end
GROUP BY p.id
ORDER BY l.creationDate DESC
获取下一个错误
SQLSTATE[42803]: Grouping error: 7 ERROR: column "l1_.creation_date" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ... p0_.creation_date >= $4 GROUP BY p0_.id ORDER BY l1_.creati...
据我所知,它表示按列分组应该在SELECT中。我不是在那里。我只需选择p(AppBundle:Photo),仅此而已。应该在dql中编辑什么才能使其正常工作?
谢谢。
答案 0 :(得分:0)
我刚刚将ORDER BY l.creationDate DESC
替换为ORDER BY p.creationDate DESC
它对我有用。据我所知,ORDER BY列应该是SELECTed