I have this code that works properly and displays the output that I want.

SELECT * 
FROM wp_users
WHERE ID NOT 
IN (
SELECT post_author
FROM wp_posts
UNION SELECT user_id
FROM wp_comments
)
AND YEAR( user_registered ) <2014
AND ID NOT 
IN (
SELECT ID
FROM wp_users
INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id
WHERE wp_usermeta.meta_key =  'wp_capabilities'
AND wp_usermeta.meta_value LIKE  '%admin%'
)
ORDER BY  `user_registered` DESC

the problem is that when i change it to this: (from select to delete)

DELETE 
FROM wp_users
WHERE ID NOT 
IN (
SELECT post_author
FROM wp_posts
UNION SELECT user_id
FROM wp_comments
)
AND YEAR( user_registered ) <2014
AND ID NOT 
IN (
SELECT ID
FROM wp_users
INNER JOIN wp_usermeta ON wp_users.ID = wp_usermeta.user_id
WHERE wp_usermeta.meta_key =  'wp_capabilities'
AND wp_usermeta.meta_value LIKE  '%admin%'
)
ORDER BY  `user_registered` DESC

I get this error:

#1093 - You can't specify target table 'wp_users' for update in FROM clause

Is there another way to execute this command getting the same results that I want?
w/c is to delete wordpress users with no posts & no comments, is not an admin and registered in year 2013 and older.

any help would be great! -thanks in advance!

Read more here: Mysql error 1093: How to delete wordpress users with no posts & no comments, is not an admin and registered in year 2013 and older


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , , , , , ,

Wordpress related questions and answers: