title: MySQL select all elements in array
body: <p>I have this array:</p>
  
  <pre><code>$results = array('1', '3', '123')
  </code></pre>
  
  <p>and this table:</p>
  
  <pre><code>id  |  item  |  tag
  1      1        1
  2      1        3
  3      1        123
  4      2        1
  5      3        1
  6      4        3
  </code></pre>
  
  <p>I want to perform a query like this:</p>
  
  <pre><code>SELECT item FROM table WHERE ALL 3 TAGS OF THE ARRAY EXIST.
  </code></pre>
  
  <p>In the example I want to return only Item=1, because it's the only Item with all 3 tags of the array.</p>
  
  <p>So far I have this:</p>
  
  <pre><code>$query .= " SELECT item FROM #__table WHERE tag IN ('";
  $query .= implode("','",$results); 
  $query .= "')"; 
  </code></pre>
  
  <p>But it does not return the correct Items, instead it returns all items that are related at least with one element of the array.</p>