2

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();
4

2 回答 2

1

Your best bet is going to be to use a Native Query if you want a single query.

于 2013-08-05T16:52:00.063 回答
1
SELECT d
FROM FLIContractBundle:DieselPrice d
WHERE d.date = (
    SELECT max(p.date)
    FROM FLIContractBundle:DieselPrice p
)
于 2013-08-05T16:55:41.033 回答