Site icon Hip-Hop Website Design and Development

How to change ID of an attachment in wp_posts and its related tables correctly?

I have two posts in my wp_posts table where post_type='attachment'
The picture below shows the records related to those in wp_postmeta table

I need to change the IDs of those files. What I am doing is:

update wp_posts 
set ID = ID + 10000 
where ID in (3143,3144); 


update wp_postmeta set post_id = post_id + 10000,
                       meta_id = meta_id + 100000
where post_id in (3143,3144); 

When I do that, I am losing the images! I don’t see it under “Media” section in wp-admin. In the webpage, they are not shown either. If I go: /wp-admin/upload.php?item=13143, it also does not come up. Only when I go to the link in the “guid” field of the related record at wp_posts, I see the image.

What am I missing? What am I doing wrong?

Any advice would be appreciated.