title: Join columns from one table to single column from another table
body: <p>I'm trying to learn how to join multiple columns from one table to a single column from another table.</p>
  
  <p>This is my table structure in its simplest form:   </p>
  
  <p><strong>teams</strong></p>
  
  <pre><code>   id | team_name |
     1  |   teamA   |
     2  |   teamB   |
     3  |   teamC   |
     4  |   teamD   |
  </code></pre>
  
  <p>There is a table named "TeamInOut"</p>
  
  <pre><code>      In    |   Out  
        -     |   teamA 
      teamB   |     -  
        -     |   teamC  
      teamD   |     -   
        -     |   teamD 
  </code></pre>
  
  <p>The results I want to get back would be:</p>
  
  <pre><code>      In    |   Out    |teamid
        -     |   teamA  |  1
      teamB   |     -    |  2
        -     |   teamC  |  3
      teamD   |     -    |  4
        -     |   teamD  |  4
  </code></pre>
  
  <p>My question is, how do I create teamid column? Please help me.</p>