4

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.

quosal
  • 167
  • 1
  • 2
  • 10
  • 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 Dec 28 '15 at 09:32

1 Answers1

1

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

Community
  • 1
  • 1
miltone
  • 4,416
  • 11
  • 42
  • 76
  • 1
    thanks for pointing out the answer; I had tried using second querybuilder in `->from` but it didn't work out – quosal Dec 30 '15 at 04:24