title: PHP MySQL - Column 'id' in IN/ALL/ANY subquery is ambiguous
body: <p>I currently have the following query working:</p>
  
  <pre><code>$sql = $db-&gt;Query("SELECT a.id FROM surf a LEFT JOIN users b ON b.id = a.user LEFT JOIN surfed c ON c.user = '".$data['id']."' AND c.site = a.id WHERE a.active = '0' AND (b.coins &gt;= a.cpc AND a.cpc &gt;= '2') AND (c.site IS NULL AND a.user !='".$data['id']."')".$dbt_value." ORDER BY a.cpc DESC LIMIT 1");
  </code></pre>
  
  <p>But I'd like to add the follow AND statements in to it:</p>
  
  <pre><code> AND `cpc`&lt;='10' AND (`id` NOT IN (SELECT `site` FROM `surfed_site`)) 
  </code></pre>
  
  <p>So i made it look like:</p>
  
  <pre><code>$sql = $db-&gt;Query("SELECT a.id FROM surf a LEFT JOIN users b ON b.id = a.user LEFT JOIN surfed c ON c.user = '".$data['id']."' AND c.site = a.id WHERE a.active = '0' AND (b.coins &gt;= a.cpc AND a.cpc &gt;= '2') AND `cpc`&lt;='10' AND (`id` NOT IN (SELECT `site` FROM `surfed_site`)) AND (c.site IS NULL AND a.user !='".$data['id']."')".$dbt_value." ORDER BY a.cpc DESC LIMIT 1");
  </code></pre>
  
  <p>But then I receive this message:</p>
  
  <p>Column 'id' in IN/ALL/ANY subquery is ambiguous</p>
  
  <p>What is wrong with my query?</p>