• Hi. I was trying to clean up some orphan data from the wp_usermeta table after deleting accounts from the wp_users table. I tried the following:

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

    But I get the following:

    Error

    SQL query: Documentation

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

    MySQL said: Documentation
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘*
    FROM wp_usermeta
    WHERE user_id NOT IN
    (SELECT ID FROM wp_users)’ at line 1

    Anyone able to help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The proper syntax for DELETE is

    DELETE FROM ...

    There’s no * in there. When it deletes it delets the entire record, not part of it, so any * would be completely redundant.

    Thread Starter connor83

    (@connor83)

    Cheers it worked perfectly.

    @connor83 or someone else :p
    Can you please give me the complete query to run?

    I have the exact same issue with about 2000 members.

    How to I fix this:
    WHERE user_id NOT IN
    —>(SELECT ID FROM wp_users)<—‘ at line 1

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Delete orphans from wp_usermeta’ is closed to new replies.