Reputation: 3209
Can I limit in a subquery without using query builder? Example:
$results = $em->createQuery('
SELECT d
FROM FLIContractBundle:DieselPrice d
WHERE d.date = (
SELECT p.date
FROM FLIContractBundle:DieselPrice p
ORDER BY p.date DESC
LIMIT 1
)
')->getResult();
Upvotes: 2
Views: 380
Reputation: 125264
SELECT d
FROM FLIContractBundle:DieselPrice d
WHERE d.date = (
SELECT max(p.date)
FROM FLIContractBundle:DieselPrice p
)
Upvotes: 1
Reputation: 1741
Your best bet is going to be to use a Native Query if you want a single query.
Upvotes: 1