title: Symfony & Doctrine getting a joined query to work
body: <p>I've got an SQL query that returns all the rows in one table (country) which have a related entry in another table (ducks) but I'm struggling to turn this into DQL. This is a standard one-many relationship as each country can have multiple ducks, I believe it is all set up correctly as I can return ducks within a country and return the country a  duck is in using standard code. </p>
  
  <p>The working query is:</p>
  
  <pre><code>SELECT c.* FROM country c 
  INNER JOIN ducks d 
  ON c.id = d.country_id 
  GROUP BY c.country 
  ORDER BY c.country ASC
  </code></pre>
  
  <p>I've tried converting this to:</p>
  
  <pre><code>SELECT c FROM WfukDuckBundle:Country c 
  INNER JOIN WfukDuckBundle:Ducks d 
  ON c.id = d.country_id 
  GROUP BY c.country 
  ORDER BY c.country ASC
  </code></pre>
  
  <p>which produces the following error:</p>
  
  <pre><code>[Semantical Error] line 0, col 79 near 'd ON': Error: Identification Variable 
  WfukDuckBundle:Ducks used in join path expression but was not defined before. 
  </code></pre>
  
  <p>I'm quite new to Symfony/Doctrine so I suspect it's probably something obvious!</p>
  
  <p>I'm using Symfony 2.0.11 with doctrine</p>
  
  <p>Update:
  I've Also tried:</p>
  
  <pre><code>SELECT c FROM WfukDuckBundle:Country c 
  INNER JOIN c.ducks d 
  ON c.id = d.country_id 
  GROUP BY c.country 
  ORDER BY c.country ASC
  </code></pre>
  
  <p>where 'ducks' is defined in the Country class as:</p>
  
  <pre><code>/**
   * @ORM\OneToMany(targetEntity="Ducks", mappedBy="country")
   */
  protected $ducks;
  
  public function __construct()
  {
      $this-&gt;ducks = new ArrayCollection();
  }
  </code></pre>
  
  <p>the definition for country in the ducks class is:</p>
  
  <pre><code>/**
  * @ORM\ManyToOne(targetEntity="Country", inversedBy="ducks")
  * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
  */
  private $country;
  </code></pre>