title: CakePHP: How to retrieve data from two tables using an inner join?
body: <p>I have two tables in a database, one as <code>user(id,first_name,last_name)</code>, and the other one as <code>location(id,country)</code>.</p>
  
  <p>I need to perform an inner join with these two tables based on the condition <code>user.id = location.id</code>, and the query result should contain the columns <code>first_name</code>, <code>last_name</code> and <code>country</code>.</p>
  
  <p>I have tried the following query in CakePHP: </p>
  
  <pre><code>$this-&gt;set('users', $this-&gt;User-&gt;find('list', array(
      'fields' =&gt; array(
          'User.id',
          'User.first_name',
          'location.country'
      ),
      array(
          'joins' =&gt; array(
              array(
                  'table' =&gt; 'location',
                  'alias' =&gt; 'location',
                  'type' =&gt; 'INNER',
                  'conditions' =&gt; array('User.id = location.id')
              )
          )
      )
  )));
  </code></pre>
  
  <p>which however produces this error:</p>
  
  <blockquote>
    <p>Unknown column 'location.country' in 'field list'</p>
  </blockquote>
  
  <p>What could be the problem?</p>