Skip to content

Instantly share code, notes, and snippets.

@thinkingcap
Forked from mikejolley/query.sql
Created March 25, 2022 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkingcap/d78c66406bbd758e99ab25c8993d0933 to your computer and use it in GitHub Desktop.
Save thinkingcap/d78c66406bbd758e99ab25c8993d0933 to your computer and use it in GitHub Desktop.
WooCommerce - SQL to Delete users with no orders or posts
DELETE from wp_users where wp_users.ID not in (
SELECT meta_value FROM wp_postmeta WHERE meta_key = '_customer_user'
) AND wp_users.ID not in (
select distinct(post_author) from wp_posts
);
delete from wp_usermeta where wp_usermeta.user_id not in (select ID from wp_users);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment