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)

Image of PulumiUP 2025

Transform Your Cloud Infrastructure

Join PulumiUP 2025 on May 6 for Expert Insights & Demos.

Register Now

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay