?
Solved

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

Posted on 2014-04-17
2
Medium Priority
?
770 Views
Last Modified: 2014-04-25
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

0
Comment
Question by:phillystyle123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:phillystyle123
ID: 40008620
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
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 total points
ID: 40009027
You're almost there.

SELECT fields FROM wp_users
    LEFT JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id
    WHERE wp_usermeta.meta_key IN ('first_name', 'last_name')
        AND (rest of your conditions here)
    GROUP BY wp_users.ID
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question