title: Select a record that has a relationship with a number of other IDs in a junction table
body: <ul>
  <li>I am using an SQLite 3 database. </li>
  <li>I have 2 tables with a many-to-many relationship. As a result, I also have a junction table to persist this relationship. Below is a representation of something similar to what I have, with made up data etc.</li>
  </ul>
  
  <p>Teacher Table:</p>
  
  <pre><code>+----+------------+
  | ID |    Name    |
  +----+------------+
  | 1  | TeacherOne |
  | 2  | TeacherTwo |
  +----+------------|
  </code></pre>
  
  <p>StudentTable:</p>
  
  <pre><code>+----+------------+
  | ID |    Name    |
  +----+------------+
  | 1  | StudentOne |
  | 2  | StudentTwo |
  +----+------------+
  </code></pre>
  
  <p>Teacher_Student (Junction Table):</p>
  
  <pre><code>+-----------+-----------+
  | TeacherID | StudentID |
  +-----------+-----------+
  |         1 |         1 |
  |         1 |         2 |
  |         2 |         1 |
  +-----------+-----------+
  </code></pre>
  
  <p>What I want is to select only the <code>TeacherID</code> which has a record linking it with both <code>StudentID</code> is 1 and <code>StudentID</code> is 2. In this case, that would give me only <code>TeacherID</code> is 1.</p>
  
  <p>I have already tried the following SQL statement:</p>
  
  <pre><code>SELECT t_s.*
  FROM Teacher_Student AS t_s
  WHERE StudentID IN (1, 2)
  </code></pre>
  
  <p>And this returns me any records that have a <code>StudentID</code> of either 1 or 2. I have searched for an answer but have been unable to find anything which has helped me so far, so asking as a last resort.</p>