title: Select all from table where another query retuns no results
body: <p>I'm creating a register web application for someone and I want to make student search to add a student to the activities register slightly more accurate.</p>
  
  <p>At the moment my prepared statement is:</p>
  
  <pre><code>("SELECT * FROM students WHERE first_name LIKE :pattern OR last_name LIKE :pattern OR id LIKE :pattern ORDER BY last_name ASC");
  </code></pre>
  
  <p>And that works great. I returns a list of all students that match the search query. However after doing that query, for each row that returns I want to check if the students.id and $_GET['activity'] do not appear in the participants table already.</p>
  
  <p>$_GET['activity'] is an ID from activities.id</p>
  
  <p><strong>The final result I want is to display all students that are not already registered on that activity.</strong></p>
  
  <p>Is this possible in one query? As if it is I'd rather do that then have to run a query on each returns result to see whether it should be displayed or not.</p>
  
  <p>I have looked into INNER JOIN as I've used it before, but I don't feel that is what I need. My main issue is how to run that query to check if each result is in the participants table already.</p>
  
  <p>Hopefully that will make sense as I'm finding it hard to work out how to word it in my head.</p>
  
  <p><strong>My table structure:</strong></p>
  
  <p><em>students</em> - id PRIMARY KEY AI, first_name (varchar255), last_name (varchar255), dob (date)</p>
  
  <p><em>activities</em> - id PRIMARY KEY AI, title (varchar255), description (varchar255)</p>
  
  <p><em>participants</em> - id PRIMARY KEY AI, student_id (INT), activity_id (INT)</p>