title: Using Laravel query builder method whereIn() with sub query
body: <p>I am developing a Web Application using Laravel 5.3. I am now having an issue with Laravel query builder method, <code>whereIn</code>.</p>
  <p>I have table like this.</p>
  <pre><code>student - id, name, dob
  course - id, code
  student_course -  student_id, course_id
  </code></pre>
  <p>What I want to do is I want to get students searching by <code>course_id</code> of student_course table without joining any table. In manual query, I do like this.</p>
  <pre><code>SELECT * FROM `student` WHERE `student`.`id` IN (SELECT `student_id` FROM `student_course` WHRE `course_id`= ?) 
  </code></pre>
  <p>So now when I try to convert it into Laravel query builder, I have a problem. Here is my code:</p>
  <pre><code>DB::table('student')-&gt;whereIn('id',[ &quot;Here I want to run sub query&quot; ])-&gt;get();
  </code></pre>
  <p>As you can see in the second parameter of <code>whereIn()</code>, I get problem. In this scenario, do I need to run raw query? How can I run raw query as second parameter? If not, how can I filter by <code>course_id</code> just in one query like above and not joining to any table?</p>