首页 > 解决方案 > 使用 phpMyAdmin 对多行进行 MySQL 替换查询

问题描述

我想用 wordpress mysql 表中的另一组行替换整个表中的一组行。

在 wp_posts 表中。

以下查询不起作用

UPDATE wp_posts 
SET 
    field_name = REPLACE(post_content,
        '<ul class="portfolio-list sort-destination" data-sort-id="portfolio">
    <li class="col-md-4 isotope-item websites">
<div class="portfolio-item"><span class="thumb-info">
<span class="thumb-info-wrapper">
<img class="img-responsive" src="https://theinternationalrealtors.com/wp-content/uploads/2020/03/feature-your-property.jpg" alt="" /></span></span></div></li>
</ul>',
        '<div class="col-md-12">
    <div class="table-responsive table-responsive-sm">
    <table class="table-bordered table-hover table-striped">
       <thead>
          <tr>
            <th>Company</th>
            <th>Name</th>
            <th>Phone</th>
            <th>Website</th>
          </tr>
       </thead>
        <tbody>
            <tr>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
            </tr>
            <tr>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
            </tr>
            <tr>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
            </tr>
        </tbody>
    </table>
    </div>
    </div>');

还有其他说法吗?有什么帮助吗?用 phpMyAdmin 来完成。或者有什么合适的wordpress插件可用?

1054 - '字段列表'中的未知列'field_name'

我用转义字符做了,但仍然错误

    UPDATE wp_posts 
SET 
    post_content = REPLACE(post_content,
'<ul class=""portfolio-list sort-destination"" data-sort-id=""portfolio"">\n
    <li class=""col-md-4 isotope-item websites"">\n
<div class=""portfolio-item"">\n
    <span class=""thumb-info"">\n
<span class=""thumb-info-wrapper"">\n
<img src=""https://theinternationalrealtors.com/wp-content/uploads/2020/03/feature-your-property.jpg"" class=""img-responsive"" alt=""""></span></span>\n
\n
</div></li>\n
</ul>',
        '<div class=""col-md-12"">\n
    <div class=""table-responsive  table-responsive-sm"">\n
    <table class=""table-bordered  table-hover table-striped"">\n
       <thead>\n
          <tr>\n
            <th>Company</th>\n
            <th>Name</th>\n
            <th>Phone</th>\n
            <th>Website</th>\n
          </tr>\n
       </thead>\n
        <tbody>\n
            <tr>\n
               <td></td>\n
               <td></td>\n
               <td></td>\n
               <td></td>\n
            </tr>\n
            <tr>\n
               <td></td>\n
               <td></td>\n
               <td></td>\n
               <td></td>\n
            </tr>\n
            <tr>\n
               <td></td>\n
               <td></td>\n
               <td></td>\n
               <td></td>\n
            </tr>\n
        </tbody>\n
    </table>\n
    </div>\n
    </div>');

标签: mysqlwordpress

解决方案


推荐阅读