title: Laravel whereIn not giving desired result
body: <p>I have the following two tables:</p>
  <pre class="lang-none prettyprint-override"><code>unotes    unote_unit
  ======    ==========
  id        unote_id
  notes     unit_id
  </code></pre>
  <p>I am trying to retrieve <code>unotes</code> row whose related <code>unit_id</code> columns exactly match an input array.</p>
  <p>So, I run following query:</p>
  <pre class="lang-php prettyprint-override"><code>$unote = UNote::whereHas('units', function ($query) use ($request) {
          $query-&gt;whereIn('units.id', $request-&gt;unit_lists);
      })
      -&gt;withCount('units')
      -&gt;having('units_count', '=', $u_list_count)
      -&gt;get()
      -&gt;pluck(&quot;id&quot;);
  </code></pre>
  <p>But, the problem with the above query is that even if it has just a single matching <code>unit_id</code>, it retrieves the data. For example I have following datasets:</p>
  <pre><code>unotes //with related unit_id
  ========
  id = 3 //49865, 49866, 49867
  id = 4  //49865, 49866
  </code></pre>
  <p>With above mentioned code, if I pass <code>[49866,55555]</code>, it should return nothing but it returns ids 3 and 4, which contain one match but not all.</p>
  <p>I have found similar question on <a href="https://laracasts.com/discuss/channels/eloquent/eloquent-wherein-all?page=1" rel="nofollow noreferrer">Laracasts</a> as well but running the query returns <code>Cardinality violation: 1241 Operand should contain 2 column(s)</code>:</p>
  <pre><code>$unote = UNote::with('units')
      -&gt;whereHas('units', function ($query) use ($request) {
          $query-&gt;selectRaw(&quot;count(distinct id)&quot;)-&gt;whereIn('id', $request-&gt;unit_lists);
      }, '=', $u_list_count)
      -&gt;get()
      -&gt;pluck(&quot;id&quot;);
  </code></pre>
  <p>I also found a similar question <a href="https://stackoverflow.com/questions/28633389/laravel-eloquent-where-in-all">here</a>, but seems it is too expensive.</p>
  <p>Here is the dummy SQL to get started: <a href="http://sqlfiddle.com/#!9/c3d1f7/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/c3d1f7/1</a></p>