title: Efficient way to select records missing in another table
body: <p>I have 3 tables. Below is the structure:</p>
  
  <ul>
  <li><code>student</code> (<code>id int, name varchar(20)</code>)</li>
  <li><code>course</code> (<code>course_id int, subject varchar(10)</code>)</li>
  <li><code>student_course</code> (<code>st_id int, course_id int</code>) -> contains name of students who enrolled for a course</li>
  </ul>
  
  <p>Now, I want to write a query to find out students who did not enroll for any course. As I could figure out there are multiple ways to fetching this information. Could you please let me know which one of these is the most efficient and also, why. Also, if there could be any other better way of executing same, please let me know.</p>
  
  <pre><code>db2 =&gt; select distinct name from student inner join student_course on id not in (select st_id from student_course)
  
  db2 =&gt; select name from student minus (select name from student inner join student_course on id=st_id)
  
  db2 =&gt; select name from student where id not in (select st_id from student_course)
  </code></pre>
  
  <p>Thanks in advance!!</p>