Last active
September 12, 2019 23:09
-
-
Save carlosleopoldo/5897789 to your computer and use it in GitHub Desktop.
Select users in WordPress without specific user meta key and user id upper than...
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 users in WordPress without specific user meta key | |
-- * Replace meta_name for your meta key | |
-- * Replace > 0 for the minimum user ID | |
SELECT wp_users.ID | |
FROM wp_users | |
WHERE wp_users.ID > 0 | |
AND wp_users.ID NOT IN ( | |
SELECT DISTINCT user_id FROM wp_usermeta WHERE meta_key = 'meta_name' | |
) | |
ORDER BY wp_users.ID ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why are we checking:
wp_users.ID > 0
?