Created
August 30, 2017 14:38
-
-
Save amikoreh/ba9f8d0a5a12c559b05cbbc2d3a0c382 to your computer and use it in GitHub Desktop.
WordPress User Profiles - Join MySQL 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 | |
u1.id, | |
u1.user_login, | |
u1.user_email, | |
m1.meta_value AS firstname, | |
m2.meta_value AS lastname, | |
from_unixtime(floor(m3.meta_value)) AS lastlogin, | |
from_unixtime(m4.meta_value) AS whenlastlogin, | |
m5.meta_value AS logincount | |
FROM %WPDB%users AS u1 | |
JOIN %WPDB%usermeta AS m1 ON (m1.user_id = u1.id AND m1.meta_key = 'first_name') | |
JOIN %WPDB%usermeta AS m2 ON (m2.user_id = u1.id AND m2.meta_key = 'last_name') | |
JOIN %WPDB%usermeta AS m3 ON (m3.user_id = u1.id AND m3.meta_key = '_um_last_login') | |
JOIN %WPDB%usermeta AS m4 ON (m4.user_id = u1.id AND m4.meta_key = 'when_last_login') | |
JOIN %WPDB%usermeta AS m5 ON (m5.user_id = u1.id AND m5.meta_key = 'when_last_login_count') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment