Link to home
Start Free TrialLog in
Avatar of phillystyle123
phillystyle123Flag for United States of America

asked on

Wordpress database - need sql that will add wp_usermeta first_name, last_name to query

I slapped together this sql which generates the users I need. I can't figure out how to add first_name and last_name to this from wp_usermeta. this is what I have so far:

Select * from wp_wpcw_user_courses,wp_wpcw_user_progress, wp_users where course_progress="100"and unit_id="457" and unit_completed_status="complete" and wp_wpcw_user_courses.user_id=wp_wpcw_user_progress.user_id and wp_wpcw_user_courses.user_id=wp_users.ID AND unit_completed_date > "2014-04-15 23:29:31"

Open in new window

Avatar of phillystyle123
phillystyle123
Flag of United States of America image

ASKER

The logic for the whole thing would be something like this
Select * from wp_wpcw_user_courses,wp_wpcw_user_progress, wp_users where course_progress="100"and unit_id="457" and unit_completed_status="complete" and wp_wpcw_user_courses.user_id=wp_wpcw_user_progress.user_id and wp_wpcw_user_courses.user_id=wp_users.ID AND unit_completed_date > "2014-04-15 23:29:31"
    LEFT JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id
        AND wp_usermeta.meta_key IN ('first_name', 'last_name')
    GROUP BY wp_users.ID

So, I'm trying to show:

ID, first_name, last_name, email
ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial