title: MySQL - How to select records that match all IN values but in 1 or more tables
body: <p>Good day, I can't seem to figure out how to do this. I'll first explain my database model:</p>
  
  <pre><code>User (user_id, name)
  Job (job_id, name)
  UserTopJob (user_id, job_id)
  UserOtherJob(user_id, job_id)
  </code></pre>
  
  <p>A user can setup his top jobs which he likes best. Those values will be saved into UserTopJob by the user_id and the job_id. The user can set some other jobs he likes into UserOtherJob as well.</p>
  
  <p>Now, what I want to do is query out users that match my job search input.
  For example, the search input is job_id 1 and 2.
  Now I want to query out the users that match BOTH job_id 1 and job_id 2, but it doesn't matter whether they are in the users top or other jobs, or divided between those two tables.</p>
  
  <p>So a user must be returned if:</p>
  
  <ul>
  <li>Both job_id 1 &amp; 2 are in top jobs</li>
  <li>Both job_id 1 &amp; 2 are in the other jobs</li>
  <li>They have both job_id 1 and 2 but in different tables</li>
  </ul>
  
  <p>The number of input ids can grow and does not have a limit. It must always match ALL input values.
  Edit: So, for example if I'm putting job_ids 1 and 2 and 3 into the query, the ids 1 AND 2 AND 3 need to be in the top or other table for that user.</p>
  
  <p>Can anybody please help me create a MySQL-query that can do this and doesn't put too much pressure on db-performance?</p>
  
  <p>Thanks in advance for helping me out here!</p>