dimirc
dimirc

Reputation: 6615

Getting joined entity and count not working

I 'm trying to execute this query but I get an error:

select c, count(i) as total 
from \Invoice i 
join i.client c 
GROUP BY i.client 

Error: Cannot select entity through identification variables without choosing at least one root entity alias.

What is wrong? I want to get all the client entity fields

Upvotes: 0

Views: 332

Answers (1)

Hikaru-Shindo
Hikaru-Shindo

Reputation: 1901

You may try this:

select c.*, count(c.id) as total 
from \Invoice i 
join i.client c 
GROUP BY c.id

I do not really know if this works but in Doctrine1's DQL implementation this would be the right way to go.

Upvotes: 0

Related Questions