title: relational database: 2 queries as one
body: <p>I have a table name= wspollokator</p>
  
  <pre><code>-----------------
  | user1 | user2  |
  -----------------
  |  1    |    3   |
  -----------------
  |  3    |    1   |
  -----------------
  |  7    |    0   |
  -----------------
  |  8    |    10  |
  -----------------
  |  9    |    0   |
  -----------------
  |  10   |    8   |
  -----------------
  </code></pre>
  
  <p>I know how to display it like above:</p>
  
  <pre><code>SELECT p1.user1, p1.user2
  FROM wspollokator p1
  LEFT JOIN wspollokator p2 ON p1.user1 = p2.user2
  WHERE p1.user1 &lt;&gt; p1.user2
  </code></pre>
  
  <p>but this is a relational table only with user ids</p>
  
  <p>in another table name: zakwalifikowani
  I have firstnames and lastnames of user1 and user2. The key is user1 user2</p>
  
  <pre><code>---------------------------------------------------
  |firstname1 | lastname1  | firstname2 | lastname2 |
  ---------------------------------------------------
  |  Tom      |  Hopkins   |   Mike     |  Ariston  |
  ---------------------------------------------------
  |  Mike     |  Ariston   |   Tom      |  Hopkins  | 
  ---------------------------------------------------
  |  Marlon   | Nickolson  |            |           |
  ---------------------------------------------------
  |  John     | Nash       |   Jason    | Lin       |
  ---------------------------------------------------
  |  Johny    | Bride      |            |           |
  ---------------------------------------------------
  |  Jason    | Lin        |   John     | Nash      |
  ---------------------------------------------------
  </code></pre>
  
  <p>How can I use columns user1 and user2 to display it like above? I think that I need use query above because this query allow me to connect people into pairs</p>