DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

How I can join with count subquery upon doctrine?

Hello can you help me with this?

https://stackoverflow.com/questions/79484363/how-i-can-join-using-counts-using-doctrine

What I try to do is run the following query:

select
    user.*,
    business_count.count
from
    user
join (
    select
        count(*) as count,
        user_id
    from
        business
    group by
        user_id) as business_count on business_count.user_id = user.id;
Enter fullscreen mode Exit fullscreen mode

Using the doctrine's query builder. But for not it does not allow me:

  [Semantical Error] line 0, col 48 near 'JOIN (SELECT': Error: Subquery is not supported here  
Enter fullscreen mode Exit fullscreen mode

Therefore, I am exploring any solutikn to this.

Top comments (0)