title: How to do the Recursive SELECT query in MySQL?
body: <p>I got a following table:</p>
  
  <pre><code>col1 | col2 | col3
  -----+------+-------
  1    | a    | 5
  5    | d    | 3
  3    | k    | 7
  6    | o    | 2
  2    | 0    | 8
  </code></pre>
  
  <p>If a user searches for "1", the program will look at the <code>col1</code> that has "1" then it will get a value in <code>col3</code> "5", then the program will continue to search for "5" in <code>col1</code> and it will get "3" in <code>col3</code>, and so on. So it will print out:</p>
  
  <pre><code>1   | a   | 5
  5   | d   | 3
  3   | k   | 7
  </code></pre>
  
  <p>If a user search for "6", it will print out:</p>
  
  <pre><code>6   | o   | 2
  2   | 0   | 8
  </code></pre>
  
  <p>How to build a <code>SELECT</code> query to do that?</p>