<tfoot id='rWmYt'></tfoot>

<small id='rWmYt'></small><noframes id='rWmYt'>

    <legend id='rWmYt'><style id='rWmYt'><dir id='rWmYt'><q id='rWmYt'></q></dir></style></legend>
    <i id='rWmYt'><tr id='rWmYt'><dt id='rWmYt'><q id='rWmYt'><span id='rWmYt'><b id='rWmYt'><form id='rWmYt'><ins id='rWmYt'></ins><ul id='rWmYt'></ul><sub id='rWmYt'></sub></form><legend id='rWmYt'></legend><bdo id='rWmYt'><pre id='rWmYt'><center id='rWmYt'></center></pre></bdo></b><th id='rWmYt'></th></span></q></dt></tr></i><div id='rWmYt'><tfoot id='rWmYt'></tfoot><dl id='rWmYt'><fieldset id='rWmYt'></fieldset></dl></div>
      <bdo id='rWmYt'></bdo><ul id='rWmYt'></ul>

    1. 导入 CSV 以更新表中的行

      Import CSV to Update rows in table(导入 CSV 以更新表中的行)

          • <bdo id='R7A7x'></bdo><ul id='R7A7x'></ul>
              <tbody id='R7A7x'></tbody>

            • <legend id='R7A7x'><style id='R7A7x'><dir id='R7A7x'><q id='R7A7x'></q></dir></style></legend>
                <tfoot id='R7A7x'></tfoot>
              1. <small id='R7A7x'></small><noframes id='R7A7x'>

              2. <i id='R7A7x'><tr id='R7A7x'><dt id='R7A7x'><q id='R7A7x'><span id='R7A7x'><b id='R7A7x'><form id='R7A7x'><ins id='R7A7x'></ins><ul id='R7A7x'></ul><sub id='R7A7x'></sub></form><legend id='R7A7x'></legend><bdo id='R7A7x'><pre id='R7A7x'><center id='R7A7x'></center></pre></bdo></b><th id='R7A7x'></th></span></q></dt></tr></i><div id='R7A7x'><tfoot id='R7A7x'></tfoot><dl id='R7A7x'><fieldset id='R7A7x'></fieldset></dl></div>
                本文介绍了导入 CSV 以更新表中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                大约有 26K 个产品(帖子),每个产品都有这样的元值:

                There are approximately 26K products (posts) and each product has meta values like this:

                post_id 列是 db 中的产品 ID,_sku (meta_key) 是每个产品的唯一 ID.

                The post_id column is the product id in db and the _sku (meta_key) is the unique id for each product.

                我收到了一个新的 CSV 文件,该文件更新了每种产品的 _sale_price (meta_key) 的所有值 (meta_value).CSV 文件如下所示:
                SKU、销售价格

                I've received a new CSV file that updates all of the values (meta_value) for _sale_price (meta_key) of each product. The CSV file looks like:
                SKU, Sale Price

                如何导入此 CSV 以仅更新基于 post_id(产品 ID)的 _sale_price 行 &_sku 值?

                How do I import this CSV to update only the _sale_price row based on the post_id (product id) & _sku value?

                输出示例:

                我知道如何在 PHP 中通过循环遍历 CSV 并选择 &为每个单个产品执行更新,但这似乎效率低下.

                I know how to do this in PHP by looping through the CSV and selecting & executing an update for each single product but this seems inefficient.

                最好使用 phpMyAdmin 并使用 LOAD DATA INFILE.

                Preferably with phpMyAdmin and by using LOAD DATA INFILE.

                推荐答案

                您可以使用临时表来保存更新数据,然后运行单个更新语句.

                You can use temporary table to hold the update data and then run single update statement.

                CREATE TEMPORARY TABLE temp_update_table (meta_key, meta_value)
                
                LOAD DATA INFILE 'your_csv_pathname' 
                INTO TABLE temp_update_table FIELDS TERMINATED BY ';' (meta_key, meta_value); 
                
                UPDATE "table"
                INNER JOIN temp_update_table on temp_update_table.meta_key = "table".meta_key
                SET "table".meta_value = temp_update_table.meta_value;
                
                DROP TEMPORARY TABLE temp_update_table;
                

                这篇关于导入 CSV 以更新表中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
              3. <small id='2n6iL'></small><noframes id='2n6iL'>

                  <tfoot id='2n6iL'></tfoot>
                    <bdo id='2n6iL'></bdo><ul id='2n6iL'></ul>

                        <tbody id='2n6iL'></tbody>

                      • <i id='2n6iL'><tr id='2n6iL'><dt id='2n6iL'><q id='2n6iL'><span id='2n6iL'><b id='2n6iL'><form id='2n6iL'><ins id='2n6iL'></ins><ul id='2n6iL'></ul><sub id='2n6iL'></sub></form><legend id='2n6iL'></legend><bdo id='2n6iL'><pre id='2n6iL'><center id='2n6iL'></center></pre></bdo></b><th id='2n6iL'></th></span></q></dt></tr></i><div id='2n6iL'><tfoot id='2n6iL'></tfoot><dl id='2n6iL'><fieldset id='2n6iL'></fieldset></dl></div>

                          <legend id='2n6iL'><style id='2n6iL'><dir id='2n6iL'><q id='2n6iL'></q></dir></style></legend>