Created
March 10, 2020 09:19
-
-
Save korynorthrop/d5200653d6a89c89bd929b3998b7e1d7 to your computer and use it in GitHub Desktop.
Inactive LearnDash user SQL query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT u.user_email, | |
um.meta_key AS "login_type", | |
from_unixtime(um.meta_value,'%c/%e/%y') AS "login_date", | |
GROUP_CONCAT(p.post_title) AS "courses" | |
FROM nPJeAgtL_users u | |
INNER JOIN nPJeAgtL_usermeta um ON um.user_id = u.id AND um.meta_key = 'learndash-last-login' | |
LEFT JOIN nPJeAgtL_learndash_user_activity lua ON lua.user_id = u.id AND lua.activity_type = 'course' | |
LEFT JOIN nPJeAgtL_posts p ON lua.course_id = p.id | |
WHERE from_unixtime(um.meta_value) < '2019-03-01 00:00:00' AND p.id IN (1947,1938,7694,1932) | |
GROUP BY u.user_login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment