Solved

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

Posted on 2014-04-17
2
746 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
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 34

Accepted Solution

by:
Dan Craciun earned 500 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to dynamically set the form action using jQuery.

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now