title: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'category_id' in IN/ALL/ANY subquery is ambiguous
body: <p>got a select within a select statement and I'm not sure why the result is ambiguous! </p>
  
  <p>my (php) function:</p>
  
  <pre><code>function FunctionName($EventId) {
  
      $database = new Connection();
      $database = $database-&gt;Connect();
      $statement = $database-&gt;prepare(" SELECT C.*
          FROM event_categories AS C
          LEFT JOIN event_in_categories as EC
          ON C.category_id = EC.category_id
          LEFT JOIN events AS E
          ON EC.EventId = E.EventId
          WHERE category_id IN
  
          (
              SELECT EC.category_id FROM event_in_categories
              WHERE EventId = :EventId
          )
  
          AND category_active = 1 ");
  
          $statement-&gt;execute(array("EventId" =&gt; $EventId));
          $Categories = $statement-&gt;fetchall(PDO::FETCH_ASSOC);
  
          if (!empty($Categories)) {
              foreach ($Categories as $Category) {
                  $CategoryArray[] = new EventCategory(null, $Category);
              }
              return $CategoryArray;
          }
  
      }
  </code></pre>
  
  <p>I specified which ID in the second select and I still get the error. (I researched, came across <a href="https://stackoverflow.com/questions/15042296/php-mysql-column-id-in-in-all-any-subquery-is-ambiguous">PHP MySQL - Column &#39;id&#39; in IN/ALL/ANY subquery is ambiguous</a> amended my second select so it specifies which ID to read and same error)</p>
  
  <p>Any help given would be much appreciated :D </p>