title: MySQL join two tables from two columns
body: <p>I'm going to join two table with two columns contain id from another table.</p>
  
  <p>Table users</p>
  
  <pre><code>id | first_name | last_name |
  ---+------------+-----------+
   1 | John       | Doe       |
   2 | Jane       | Doe       |
   3 | Some       | Name      |
  </code></pre>
  
  <p>Table stamp</p>
  
  <pre><code>id |    date    | applicant_id  | app_by_id |
  ---+------------+---------------+-----------+
   1 | 2013-03-15 | 1             | 2         |
   2 | 2013-03-10 | 2             | 3         |
   3 | 2013-03-13 | 2             | 1         |
  </code></pre>
  
  <p>What I want to show:</p>
  
  <pre><code>    date    | applicant | app_by    |
  ------------+-----------+-----------+
   2013-03-15 | John Doe  | Jane Doe  |
   2013-03-10 | Jane Doe  | Some Name |
   2013-03-13 | Jane Doe  | John Doe  |
  </code></pre>
  
  <p>My query:</p>
  
  <pre><code>SELECT CONCAT_WS(' ', NULLIF(t1.first_name, ' '), NULLIF(t1.last_name, ' ')) AS applicant,
      CONCAT_WS(' ', NULLIF(t1.first_name, ' '), NULLIF(t1.last_name, ' ')) AS app_by,
      t2.date
      FROM users t1
      INNER JOIN stamp t2 ON applicant_id = t1.id
  </code></pre>
  
  <p>I know there's something wrong with my query, but I don't know how to fix it.</p>