doctrine2和mysql。。。
我想得到最新的一行数据。
infoaccount表
recordDate score id
2018-10-10 99 A // I need this row.
2018-10-9 88 B
2018-10-8 77 C
所以我用这个代码。
$query = $this->getEntityManager()->createQuery(
'SELECT MAX(t.recordDate)
FROM App\Entity\InfoAccount t')
它只返回t.date的最大值。我想要整排。
它一定很简单,,,,,
感谢@scaisedge
----我是这样更新的。
'SELECT t
FROM App\Entity\InfoAccount t
INNER JOIN (SELECT MAX(recordDate)
as max_date FROM App\Entity\InfoAccount) k
ON t.max_date = k.recordDate '
但是它显示了错误 Error: Subquery is not supported here
1条答案
按热度按时间4nkexdtk1#
您可以尝试在子查询中使用where日期