firstly, I'm new to polling multiple tables, so I'm sorry if this is a bit of a dumb question, but we all have to start somewhere!
I took a picture that should make it easier to understand:
http://www.mediumsliced.co.uk/temp/mysqlhelp.jpg
My first wp_user table has several columns - I need values from 3 columns, which are user_email and user_nicename IDs.
My second wp_usermeta strong> table has 3 columns that store metadata for users. These columns are user_id, meta_key and meta_value. The user_id values in this table always match the values of the match identifier in wp_user (see Figure).
I would like to join the data from the meta_key fields along with meta_value. So far I have this:
SELECT wp_users.ID, wp_users.user_login, wp_users.user_nicename, wp_users.user_email, wp_usermeta.user_id, wp_usermeta.meta_key, wp_usermeta.meta_value FROM wp_users, wp_usermeta WHERE (wp_users.ID = wp_usermeta.user_id);
This displays all the information I need, but the problem is that I really want to display the data from meta_key as separate columns and the meta value for this meta key in the correct row for this user based on their identifier. I also need to exclude all users who do not have wp_user_level as 0. (Again, hopefully this is clearer in my image that I provided)
Obviously, I need to learn a lot when it comes to MySql, but if someone could lead me to the final result, I would be very grateful, especially if you could explain the request so that I could learn from it, and not on just copy and paste it into place.
Thank you very much, if you need more information or if I need to clarify something, then feel free to ask!
Craig