I am trying to use the following code to update my post_title
column by removing the first word in it.
UPDATE wp_posts
SET post_title = (
SELECT SUBSTRING(post_title, LOCATE(' ', post_title)+1) as post_title
FROM wp_posts
WHERE post_type = 'post');
When using just this code
SELECT SUBSTRING(post_title, LOCATE(' ', post_title)+1) as post_title
FROM wp_posts
WHERE post_type = 'post';
It doesn't give out any errors, and it shows a list of all the rows with everything updated, but when I go back to the table, nothing is actually updated. I'm assuming that's because this just selects all of the rows or something. That's why I tried the update code, which is not working and giving the following error
You can't specify target table 'wp_posts' for update in FROM clause
Can someone tell me what's wrong with my code