【问题标题】:Convert SELECT statement to an UPDATE statement - MySQL/phpMyAdmin将 SELECT 语句转换为 UPDATE 语句 - MySQL/phpMyAdmin
【发布时间】:2018-09-17 16:25:29
【问题描述】:

在搜索和浏览google寻求帮助后,我终于得到了我需要的代码。它工作正常。但...!它适用于 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'

附:顺便说一句,它是 wordpress 数据库。

【问题讨论】:

  • 您是否尝试将UPDATE 您的post_content 列添加到您创建的表达式中?即 col1 到 col2?
  • 没错。

标签: mysql sql wordpress mariadb


【解决方案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'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-17
    • 2020-06-29
    • 1970-01-01
    • 1970-01-01
    • 2015-01-05
    • 1970-01-01
    相关资源
    最近更新 更多