简体   繁体   中英

Convert SELECT statement to an UPDATE statement - MySQL/phpMyAdmin

After researching and browsing google for help, I finally got the code I need. It works fine. But...! It works fine with SELECT, but how do I convert it to UPDATE statement?

SELECT
  post_content,
  concat(
    substr(post_content, 1, length(post_content) - length(substring_index(post_content,'<!--more-->',-1)) - 1))
FROM `wp_posts`
WHERE post_status='publish' AND post_type='post'

PS Btw, it is wordpress database.

I think there are a fair amount of resources on this...

UPDATE `wp_posts` t
SET t.post_content = 
concat(substr(t.post_content, 1, length(t.post_content) - 
        length(substring_index(t.post_content,'<!--more-->',-1)) - 1)) 
WHERE t.post_status='publish' AND t.post_type='post'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM