MYSQL Query on wp_usermeta
-
I’m trying, rather unsuccessfully to query and display in table form, the wp_usermeta table consisting of the standard columns: umeta_id, user_id, meta_key and meta_value.
For example sake, I want to display a query that shows first_name and last_name as headers in adjacent table columns that returns their relative value. Since first_name and last_name are not columns in their own right, but a meta_key value with an associated value stored in meta_value, I don’t know how to go about this.
USER_ID | FIRST_NAME | LAST_NAME
1 | Fred | Flintstone
2 | George | JetsonIdeally, I’d also like to be able to JOIN the wp_users table somehow in order to display an additional column from that table, where wp_usermeta.user_id = wp_users.ID, for example:
USER_ID | FIRST_NAME | LAST_NAME | DISPLAY_NAME
1 | Fred | Flintstone | Fred Flintstone
2 | George | Jetson | George JetsonI understand this is not directly a WordPress question, it’s more MYSQL (which I’m a newb at), but it is relative to the standard way in which WordPress stores user meta data. So I would be truly grateful for pointers in the right direction.
- The topic ‘MYSQL Query on wp_usermeta’ is closed to new replies.