title: Fetch unique values from cross reference table
body: <p>Right Now I have a cross reference table that looks like this:</p>
  
  <pre><code>       Table job2pos
  ╔═══════════╦═════════════╗
  ║  job_id   ║ position_id ║
  ╠═══════════╬═════════════╣
  ║  1        ║  10         ║
  ║  2        ║  10         ║
  ║  2        ║  12         ║
  ║  3        ║  11         ║
  ║  3        ║  13         ║
  ║  4        ║  10         ║
  ║  5        ║  13         ║
  ╚═══════════╩═════════════╝
  </code></pre>
  
  <p>I want to select all the <code>job_id</code> that have the <code>postion_id = 10</code> and <code>position_id = 12</code>, which would result in <code>job_id = 1,2,2,4</code>. But I only want <code>job_id = 2</code> to appear only once in my fetched result.</p>
  
  <p>The code I tried are as follow:</p>
  
  <pre><code>$positions = ["10","12"];
  
  $sql = "SELECT job2pos.job_id FROM job2pos
  WHERE job2pos.pos_id IN (?,?)";
  
  $stmt = $pdo-&gt;prepare($sql);
  
  foreach ($positions as $key =&gt; &amp;$val) {
    $stmt-&gt;bindParam($key, $val, \PDO::PARAM_INT);
  }
  
  $stmt-&gt;execute();
  
  var_dump($stmt-&gt;fetchAll(\PDO::FETCH_UNIQUE));
  </code></pre>
  
  <p>And the above attempt will produce the follow result:</p>
  
  <pre><code>array(3) {
    [1]=&gt; array(0) {}
    [2]=&gt; array(0) {}
    [4]=&gt; array(0) {}
  }
  </code></pre>
  
  <p>So I did get unique values and the extra 2 is not repeating, but how do I make it so that the <code>job_id</code> does not appear as an index but instead an value in side an array?</p>
  
  <ul>
  <li>P.S. If you can point out any unnecessary code in my code that will be great as well.</li>
  </ul>