title: SQL Multiple values from same column with inner join
body: <p>I am looking to join data from one table to another. The problem I have is in table two, the data I need is in the same column. </p>
  
  <p>This is using wordpress/woocommerce DB so as you may be aware a lot of the user data is stored in the user meta table and you extract it by selecting the meta value where meta key = <em>something</em></p>
  
  <p>Rough data structure for user meta table</p>
  
  <pre><code>id | user_id | meta_key | meta_value
  </code></pre>
  
  <p>Now I select from table 1, inner join to table 2 and use the IN operator to select the meta values I want based on meta_key</p>
  
  <pre><code> select wp_xxxxxx_users.ID, wp_xxxxxx_users.user_email, wp_xxxxxxxxx.meta_value
      from wp_xxxxxx_users
      INNER JOIN wp_xxxxxx_usermeta on wp_xxxxxx_users.ID=wp_xxxxxx_usermeta.user_id
      WHERE wp_xxxxxx_usermeta.meta_key IN ('last_name', 'first_name')
  </code></pre>
  
  <p>Now this returns all the data fine but in this format</p>
  
  <pre><code>id | user_email | meta_value
  </code></pre>
  
  <p>So what's wrong? Well I would like the meta_value columns to appear on the same row rather than multiple rows</p>
  
  <p>I want the output to do the following</p>
  
  <pre><code>id | user_email | metavalue-first_name | metavalue-last_name
  </code></pre>
  
  <p>As it's currently outputting like so</p>
  
  <pre><code>1 | test@test.com | first name
  1 | test@test.com | lastname name
  2 | test1@test.com | first name
  2 | test1@test.com | lastname name
  </code></pre>
  
  <p>I have a looked around relevant threads and seen people accomplishing this by Group By but I couldn't get it to work</p>
  
  <p>Version is MySQL 5.7.27</p>