4
votes

In a Symfony2 project:

select * from
(
    select
        p.name as product, u.id, u.name
    from user u
    left join product_purchase pp on pp.user_id = u.id
    left join product p on pp.product_id = pp.product_id
    where p.type = 'something'
    order by p.id desc
) as up
group by up.id;

This is simplified query I want build with Doctrine Query Builder but couldn't find a solution yet. The important thing is ordering on join before grouping the result. Any help would be much appreciated.

1
What is up.id in your example supposed to be? Is it u.id from the subquery? Can you give an example of how the data in your database look like and what result you would like to get returned? - xabbuh

1 Answers

1
votes

this is a example may help you because vote and check good response. He use a second queryBuilder var in a first qb with $qb->expr()->in( : subquery in queryBuilder Doctrine