Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:32:42+00:00 2026-05-27T04:32:42+00:00

I am working in MYSQL and need to extract user data to be pulled

  • 0

I am working in MYSQL and need to extract user data to be pulled into a view. I will be using the data in an email client, so I cannot do this in the app layer.

The problem is that each data field for the user is contained in separate rows (this is how WordPress sets up the data structure).

For example, wp_usermeta has multiple rows of data for each user like this:

user_id   meta_key       meta_data
   2      first_name     Jane
   2      last_name      Austin
   2      email          jane@me.com
   3      first_name     Jack
   3      last_name      Palmer
   3      email          jack@me.com

I need the data to be combined into one row, separate fields, like this:

user_id  first_name  last_name  email
2        Jane        Austin     jane@email.com
3        Paul        Parker     jack@email.com

I have searched around and cannot find this exact problem anywhere (I found a lot of concatenation, but that is not what I need).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:32:43+00:00Added an answer on May 27, 2026 at 4:32 am

    If these are the only columns you are concerned with, this will work for you:

    SELECT um.user_id
       , fn.meta_data AS first_name
       , ln.meta_data AS last_name
       , e.meta_data AS email
    FROM wp_userMeta AS um
    LEFT JOIN wp_user_Meta AS fn ON um.user_id = fn.user_id
       AND fn.meta_key = 'first_name'
    LEFT JOIN wp_user_Meta AS ln ON um.user_id = ln.user_id
       AND ln.meta_key = 'last_name'
    LEFT JOIN wp_user_Meta AS e ON um.user_id = e.user_id
       AND e.meta_key = 'email'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with a MySQL query that writes into an outfile. I run this
I have three MySQL queries I need to combine into a single query using
I am working on a project where I need to extract data from a
I need to insert some data into a mysql database. Db is connected and
I've developed an application at working using MySQL 5, that uses Views to access
I'm working with a MySQL database that has some data imported from Excel .
My insert and update pages (through my admin forlder) into mysql stopped working. When
I am working with a MySQL Database and I need to store rich text
I am working with Python MySQL, and need to clean a table in my
I'm working with mySQL, and I'm in a situation where I need to select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.