Change media attachment author via mysql query

How does one bulk change the media attachment author via an sql query?

I have hundreds of media attachments that need to be moved to another author so the original author can be deleted; but that author has no posts, only media attachments.

Read More

(The images were attributed to the author when importing and running a query to take the first post image and make it a featured image.)

I think I need to specify the `post_type’ in a query, like this:

update wp_posts and post_type = ‘attachment’

Update:

As answered below, this works
UPDATE wp_posts SET post_author = [NEW_ID] WHERE post_author = [OLD_ID]

with or without the AND post_type = 'attachment'

Related posts

Leave a Reply

1 comment