title: MySQL query joining
body: <p>I have a MySQL question. It is related to <a href="https://stackoverflow.com/questions/21398061/use-result-from-query-in-same-query">this other question that I asked previously</a>, but slightly different.</p>
  
  <p>I have 2 tables: Teams, Contractors</p>
  
  <pre><code>TEAMS
  |team_id | location|
  --------------------
  |    1   |  space1 |
  --------------------
  |    2   |  space2 |
  --------------------
  |    3   |  space3 |
  --------------------
  |    4   |  space3 |
  --------------------
  </code></pre>
  
  <hr>
  
  <pre><code>CONTRACTORS
  |cont_id | location| team_id|
  -----------------------------
  |    1   |  space1 |    1   |
  -----------------------------
  |    2   |  space1 |    0   |
  -----------------------------
  |    3   |  space3 |    3   |
  -----------------------------
  |    4   |  space3 |    3   |
  -----------------------------
  |    5   |  space3 |    0   |
  -----------------------------
  |    6   |  space3 |    4   |
  -----------------------------
  </code></pre>
  
  <p>If I'm given a team_id, I would like to create a query that finds all the contractors that are at the location of the given team_id AND belong only to the given team_id or with a <code>team_id = 0</code>.  (<code>team_id = 0</code> in the CONTRACTORS table means the contractor is not currently part of a team). </p>
  
  <p>For example, I'm given the <code>team_id = 3.</code> The team with <code>team_id = 3</code> is located at space3. I want to find the contractors that are located at space3 and belong only to <code>team_id = 3</code> or <code>team_id = 0</code> (cont_id = 3, 4, 5 in this example).</p>
  
  <p>Is there a way to achieve this with a single MySQL query? </p>