Skip to content

Instantly share code, notes, and snippets.

@natematias
Created December 1, 2010 16:11
Show Gist options
  • Select an option

  • Save natematias/723705 to your computer and use it in GitHub Desktop.

Select an option

Save natematias/723705 to your computer and use it in GitHub Desktop.
one record per WordPress user account
SELECT wp_users.user_login, wp_users.user_nicename, wp_users.user_email
GROUP_CONCAT(CONCAT(meta_key, ": ", meta_value)),
FROM wp_users JOIN wp_usermeta ON wp_users.id = wp_usermeta.user_id
GROUP BY wp_users.user_login;
@natematias
Copy link
Author

Sometimes, I want to know all of the information about a given wordpress user in one row. This is made difficult by the key/value table usermeta. Here is the query I use to select that information into one row per user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment