title: How can I pull data from specific rows via SQL and separate them into their own columns?
body: <p>I apologize if I cannot explain this properly in advance but I will do my best. </p>
  
  <p>I have a SQL table. In the table, there are multiple columns. One of which is labeled 'meta_key' and another which is 'meta_value'. I would like to know how to write SQL that will pull specific rows in one column and also gather the data from another column in the same row and separate all of these out into their own columns. (Please forgive me if this doesn't make sense.) </p>
  
  <p>I've tried the following which was provided by a friend:</p>
  
  <pre><code>SELECT meta_key, meta_value
  FROM wp_gf_entry_meta
  WHERE meta_key = 3 OR meta_key = 9 OR meta_key = 22 OR meta_key = 23 
  </code></pre>
  
  <p>But it only gets me halfway there in that it provides all of the data from those rows and columns and consolidates it all into a single column.</p>
  
  <p>Again, the SQL that was tried was:</p>
  
  <pre><code>SELECT meta_key, meta_value
  FROM wp_gf_entry_meta
  WHERE meta_key = 3 OR meta_key = 9 OR meta_key = 22 OR meta_key = 23 
  </code></pre>
  
  <p>I didn't receive error messages for above but it did not provide the desired outcome.</p>
  
  <p>Here is a screenshot of the table before the above SQL:</p>
  
  <p><a href="https://i.stack.imgur.com/QDlpE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QDlpE.png" alt="Here is a screenshot of the table before the above SQL:"></a></p>
  
  <p><a href="https://i.stack.imgur.com/28jLu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/28jLu.png" alt="and afterd"></a></p>
  
  <p>And here is a screenshot after:</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've made some progress. I believe what they call an 'Aggregate Function' is what I can use.</p>
  
  <p>This has gotten me closer to my goal:</p>
  
  <pre><code>  SELECT 
    max(case when meta_key = 3 then meta_value end) Ticker,
    max(case when meta_key = 9 then meta_value end) Reason,
    max(case when meta_key = 22 then meta_value end) Resistance,
    max(case when meta_key = 23 then meta_value end) Support
    from wp_gf_entry_meta
  </code></pre>
  
  <p>The only problem now is that it only returns one row and I'm not certain how to make it return more than one row. </p>