Site icon Hip-Hop Website Design and Development

Query to Get All Users from wp_users With NO matching user_id In wp_usermeta

I’m currently trying to get all users from wp_users that have no matching ID entry in wp_usermeta (matching on user_id).

I have a site with a very large user base that currently has thousands of spam users.

The following query is returning no records:

SELECT * FROM wp_users
WHERE ID NOT IN (
SELECT user_id FROM wp_usermeta);

I’ve already removed the bad records from the meta table which is why I need to query to find only the records with no associated ID in wp_users.