title: Combine two tables into one in MySQL
body: <p>Suppose I have two tables named <code>users</code> and <code>offers</code></p>
  
  <p><code>users</code> table</p>
  
  <pre><code>+----+----------+-----------+
  | id | username | role      |
  +----+----------+-----------+
  | 1  | A        | client    |
  +----+----------+-----------+
  | 2  | B        | client    |
  +----+----------+-----------+
  | 3  | C        | candidate |
  +----+----------+-----------+
  | 4  | D        | candidate |
  +----+----------+-----------+
  | 5  | E        | candidate |
  +----+----------+-----------+
  </code></pre>
  
  <p><code>offers</code> table</p>
  
  <pre><code>+----+-----------+--------------+
  | id | client_id | candidate_id |
  +----+-----------+--------------+
  | 1  | 1         | 3            |
  +----+-----------+--------------+
  | 2  | 2         | 4            |
  +----+-----------+--------------+
  | 3  | 1         | 5            |
  +----+-----------+--------------+
  | 4  | 2         | 3            |
  +----+-----------+--------------+
  | 5  | 2         | 5            |
  +----+-----------+--------------+
  </code></pre>
  
  <p>I want to create a query to combine <code>offers</code> table with <code>users</code> table, like</p>
  
  <pre><code>+----+-----------+-----------------+--------------+--------------------+
  | id | client_id | client_username | candidate_id | candidate_username |
  +----+-----------+-----------------+--------------+--------------------+
  | 1  | 1         | A               | 3            | C                  |
  +----+-----------+-----------------+--------------+--------------------+
  | 2  | 2         | B               | 4            | D                  |
  +----+-----------+-----------------+--------------+--------------------+
  | 3  | 1         | A               | 5            | E                  |
  +----+-----------+-----------------+--------------+--------------------+
  | 4  | 2         | B               | 3            | C                  |
  +----+-----------+-----------------+--------------+--------------------+
  | 5  | 2         | B               | 5            | E                  |
  +----+-----------+-----------------+--------------+--------------------+
  </code></pre>
  
  <p>I have written 2 queries that are working separately, but I want to combine these into one table.</p>
  
  <pre><code>SELECT offers.candidate_id, users.username AS candidate_username
  FROM offers INNER JOIN users ON offers.candidate_id = users.id;
  
  SELECT offers.client_id, users.username AS client_username
  FROM offers INNER JOIN users ON offers.client_id = users.id;
  </code></pre>