I have 2 entity:
/**
* @ORM\\Entity
* @ORM\\Table(name=\"users\")
*/
class User
{
/**
* @ORM\\ManyToMany(targetEntity=\"Myapp\\UserBundle\\Entity
It's a ManyToMany relation, don't event try to join on the relation table, only the related entity... Then, you were right with the RIGHT JOIN ... for a SQL query, but Doctrine automatically defines the jointure type from the FROM clause.
In DQL, only defined relations are managed by jointures, so you don't need USE or ON clauses...
What about this one ?
SELECT g.name, g.id, count( u.id )
FROM groups g
JOIN users u
GROUP BY g.id