我想写一个查询(与子查询),但我不知道如何在我的子查询设置限制。 我的查询:设定LIMIT与教义2?
$query_ids = $this->getEntityManager()
->createQuery(
"SELECT e_.id
FROM MuzichCoreBundle:Element e_
WHERE [...]
GROUP BY e_.id")
->setMaxResults(5)
;
$query_select = "SELECT e
FROM MuzichCoreBundle:Element e
WHERE e.id IN (".$query_ids->getDql().")
ORDER BY e.created DESC, e.name DESC"
;
$query = $this->getEntityManager()
->createQuery($query_select)
->setParameters($params)
;
但- > setMaxResults(5)不起作用。 SQL查询中没有“LIMIT”。我们能做简单的LIMIT与教条2吗?
的MySQL还不支持 '限制和IN/ALL/ANY/SOME子查询' – 2016-11-07 16:14:10