title: Mysql - Merge multiple columns into one while preserving each value
body: <p>Is there a simple way in Mysql to convert a multi-column resultset into a single-column resultset where each row in the single column contains a single value from each cell in the multi-column resultset?</p>
  
  <p>For instance, say I have a table like:</p>
  
  <pre><code>    id    |   fk1   |   fk2   |   fk3   
      1          2         3         4
      5          6         7         8
  </code></pre>
  
  <p>Ideally I'd like to be able to run a query along the lines of:</p>
  
  <pre><code>SELECT &lt;some_function&gt;(fk1, fk2, fk3) AS value FROM myTable;
  </code></pre>
  
  <p>...and then get an output like:</p>
  
  <pre><code>  value  
      2
      3
      4
      6
      7
      8
  </code></pre>
  
  <p>Is there a straightforward way of doing so, or is the only real option to walk the multi-column resultset in code and extract the values into the format that I want?</p>
  
  <p>The end goal is to be able to use the first query as a subquery in a context where the input can only be a single column of values, like:</p>
  
  <pre><code>SELECT * FROM myOtherTable WHERE id IN 
      (SELECT &lt;some_function&gt;(fk1, fk2, fk3) AS value FROM myTable);
  </code></pre>
  
  <p>Thus a pure SQL solution is preferable, if one exists.  </p>