title: cakephp combining two sql statements
body: <p>hi all  I have two sql statements in my function, I want to take the result of the $accounts and use that as the where clause in my second statement. I am trying to get the account_id from the accounts_users table so I can get the relevant templates to that account. </p>
  
  <p>the two finds are called $templates and $accounts, I want the result of the first query to be used for what template.account_id= 'answer' is.</p>
  
  <pre><code>SELECT `AccountsUser`.`id`, `AccountsUser`.`account_id` FROM `pra`.`accounts_users` AS `AccountsUser` WHERE `id` = 14 LIMIT 1
  
  SELECT `Template`.`id`, `Template`.`name`, `Template`.`description`, `Template`.`account_id` FROM `pra`.`templates` AS `Template` WHERE `Template`.`account_id` = ''
  </code></pre>
  
  <p>this is the code in my controller</p>
  
  <pre><code>$this-&gt;Template-&gt;unbindModel(array('belongsTo'=&gt;array('Account')));
          $templates = $this-&gt;Auth-&gt;user('name');
          $accounts=$this-&gt;User-&gt;AccountsUser-&gt;find('first', array('fields'=&gt;array('id','account_id'),'conditions' =&gt;     array('id' =&gt; $this-&gt;Auth-&gt;user('id'))));
          $this-&gt;set('Templates', $this-&gt;Template-&gt;find('all', array('conditions' =&gt; array('Template.account_id' =&gt; $accounts))));
          $this-&gt;set('templates', $templates);
          $this-&gt;set('accounts'. $accounts);
  </code></pre>
  
  <p>view 'view'</p>
  
  <pre><code>&lt;div class = "conlinks"&gt;        
  
  &lt;table width="100%" border="1"&gt;
  
              &lt;table width="100%" border="1"&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Template Name&lt;/th&gt;
                      &lt;th&gt;Template Description&lt;/th&gt;
  
                  &lt;/tr&gt;
  
                  &lt;?php foreach($templates as $template): ?&gt;
                      &lt;tr&gt; 
                          &lt;td align='center'&gt;&lt;?php echo $template['Template']['name']; ?&gt;&lt;/td&gt;
                          &lt;td align='center'&gt;&lt;?php echo $template['Template']['description']; ?&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;?php endforeach; ?&gt;
  
              &lt;/table&gt;
  
  &lt;/div&gt;              
      &lt;/table&gt;
  </code></pre>