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)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay