title: How to select pairs of columns with SQL
body: <p>I can't fit the question into one sentence so I will give an example. Say you have the following tables in your database:</p>
  
  <pre><code>Users(id, name)
  Friends(id1, id2)
  </code></pre>
  
  <p><code>Friends(id1)</code> and <code>Friends(id2)</code> are both foreign keys that reference <code>Users(id)</code>. What would the query look like to get the user id on one side and all friends on the other side. The data in the friends table looks something like this:</p>
  
  <pre><code>id1 id2
  -------
   1  2
   1  3
   1  4
   2  3
   2  4
   2  5
   5  1
  </code></pre>
  
  <p>And I want an output like this:</p>
  
  <pre><code>id1 id2
  -------
   1  2
   1  3
   1  4
   1  5
   2  1
   2  3
   2  4
   2  5
   3  1
   3  2
   4  1
   4  2
   5  1
   5  2
  </code></pre>
  
  <p>All user IDs should be on the left and the friends of that user ID should all be on the right. I think I have to do some sort of cross product but I can't get the correct output. Any ideas how to do this? Thanks.</p>