title: Link rows in a MySQL table
body: <p>I have a question about MySQL. I have this table structure:</p>
  
  <pre><code>ID      Name
  ------  ------------
  1       Peter
  2       John
  3       Carl
  4       William
  </code></pre>
  
  <p>I need to link the record. 
  I.e. 
  - Peter is related to Carl and William
  - Carl is related to John</p>
  
  <p>Should I make a new table like this:</p>
  
  <pre><code>ID1     ID2
  ------  ------------
  1       3
  1       4
  3       2
  </code></pre>
  
  <p>Or should I extend the first table like this:</p>
  
  <pre><code>ID      Name          Links
  ------  ------------  ----------
  1       Peter         3,4
  2       John
  3       Carl          2
  4       William
  </code></pre>
  
  <p>In both cases, how do I make a query that returns:</p>
  
  <pre><code>Name          LinkedName
  ------------  --------------
  Peter         Carl
  Peter         William
  </code></pre>
  
  <p>I have considered to use JOIN, UNION and sub-queries, but I can not really get it to work.
  I really hope that somebody can help me here. </p>
  
  <p>Thanks.</p>