将SELECT语句转换为UPDATE语句 - MySQL / phpMyAdmin

时间:2018-04-08 00:05:34

标签: mysql sql wordpress mariadb

在研究和浏览谷歌寻求帮助后,我终于得到了我需要的代码。它工作正常。但...!它适用于SELECT,但如何将其转换为UPDATE语句?

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'

P.S。顺便说一下,它是wordpress数据库。

1 个答案:

答案 0 :(得分:1)

我认为这方面有相当多的资源......

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'
相关问题