phillystyle123
asked on
sql query: Need to add Join to query that already has left join
My query is working perfectly. It's gleaning login, email first name and last name from wordpress tables: users and usermeta.
I need to add the field: course_progress from table: wp_wpcw_user_courses using "user_id" to join everything. My issue is that I'm already using "user_id" to join users and usermeta.
Here's my query so far using users and usermeta:
I need to add the field: course_progress from table: wp_wpcw_user_courses using "user_id" to join everything. My issue is that I'm already using "user_id" to join users and usermeta.
Here's my query so far using users and usermeta:
SELECT
wp_users.user_login,
MAX(CASE WHEN wp_usermeta.meta_key = 'first_name' then wp_usermeta.meta_value ELSE NULL END) as first_name,
MAX(CASE WHEN wp_usermeta.meta_key = 'last_name' then wp_usermeta.meta_value ELSE NULL END) as last_name,
wp_users.user_email
FROM wp_users
LEFT JOIN wp_usermeta
ON wp_users.ID = wp_usermeta.user_id
GROUP BY wp_users.user_login ORDER BY 3 asc
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER