I am trying to query a list of user id's in WordPress using SQL IN() with the addition of them having a meta_value value of "Yes" on the meta_key "is_registered" in the wp_usermeta table but I can't seem to get this to work. It just returns 0 results. If I use just the IN() with the array of ID's, it works fine.
Here is what I am using:
SELECT DISTINCT wp_users.ID FROM wp_users LEFT JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) WHERE wp_users.ID IN(23,643,574,617,26) AND wp_usermeta.meta_key = 'is_registered' AND wp_usermeta.meta_value = 'Yes'
This must be SQL. I can't use WP_User_Query() as it's for a personal project of mine whereby I'd like to use SQL.
Can anyone see what I am doing wrong here as I've been racking my brain with it for what feels like forever now!