Hello, firstly I'm new to querying multiple tables so I apologise if this is a bit of a stupid question, but we all have to start somewhere!
I've made a picture which should make this easier to understand:
My first table wp_user has several columns - I want the values from 3 columns which are ID user_email and user_nicename.
My second table wp_usermeta has 3 columns which stores meta data for the users. These columns are user_id, meta_key and meta_value. The user_id values in this table always correspond to the matching ID values in wp_user (see picture).
I would like to join data from the meta_key fields along with it's 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 info I need however the issue I have is that I actually want to display the data from meta_key as individual columns and the meta_value for that meta key in the correct row for that user based on their ID. I also need to exclude any users which do not have their wp_user_level as 0. (Again hopefully this is clearer on my picture I provided)
Obviously I have a lot to learn when it comes to MySql but if anyone could guide me to the end result I'd be really grateful, even more so if you could explain the query so that I can learn from it as opposed to just copy and paste it in place.
Thanks a lot if you need more information or need me to clarify anything then feel free to ask!
Craig