1. <legend id='26wio'><style id='26wio'><dir id='26wio'><q id='26wio'></q></dir></style></legend><tfoot id='26wio'></tfoot>

      <small id='26wio'></small><noframes id='26wio'>

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

          <bdo id='26wio'></bdo><ul id='26wio'></ul>
      1. 使用同一表中另一行的数据更新行

        Update row with data from another row in the same table(使用同一表中另一行的数据更新行)

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

          <tfoot id='rmFNu'></tfoot>
        • <legend id='rmFNu'><style id='rmFNu'><dir id='rmFNu'><q id='rmFNu'></q></dir></style></legend>
            • <bdo id='rmFNu'></bdo><ul id='rmFNu'></ul>

                <tbody id='rmFNu'></tbody>

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

                1. 本文介绍了使用同一表中另一行的数据更新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一张看起来像这样的桌子

                  I've got a table which looks something like this

                  ID   |   NAME    |  VALUE  |
                  ----------------------------
                   1   |   Test    |  VALUE1 |
                   2   |   Test2   |  VALUE2 |
                   1   |   Test2   |         |
                   4   |   Test    |         |
                   1   |   Test3   |  VALUE3 |
                  

                  我正在寻找一种方法来更新值 'Test2' 和 'Test' 与来自'VALUE' 列中具有相同'NAME' 的其他行的数据(ID 在这里不是唯一的,复合键ID 和 NAME 使一行唯一).例如,我正在寻找的输出是:

                  I'm looking for a way to update the values 'Test2' and 'Test' with the data from other rows in the 'VALUE' column with the same 'NAME' (The ID is not unique here, a composite key of the ID and NAME make a row unique). For example, the output I'm looking for is:

                  ID   |   NAME    |  VALUE  |
                  ----------------------------
                   1   |   Test    |  VALUE1 |
                   2   |   Test2   |  VALUE2 |
                   1   |   Test2   |  VALUE2 |
                   4   |   Test    |  VALUE1 |
                   1   |   Test3   |  VALUE3 |
                  

                  如果它在另一个表中,我会很好,但我不知道如何引用当前表中具有相同 NAME 值的不同行.

                  If it was in another table I'd be fine, but I'm at a loss as to how I can reference a different row within the current table with the same NAME value.

                  更新

                  修改 manji 查询后,以下是我用于工作解决方案的查询.谢谢大家!

                  After modifying manji query, below is the query I used for a working solution. Thanks all!

                  UPDATE data_table dt1, data_table dt2 
                  SET dt1.VALUE = dt2.VALUE 
                  WHERE dt1.NAME = dt2.NAME AND dt1.VALUE = '' AND dt2.VALUE != '' 
                  

                  推荐答案

                  试试这个:

                  UPDATE data_table t, (SELECT DISTINCT ID, NAME, VALUE
                                          FROM data_table
                                         WHERE VALUE IS NOT NULL AND VALUE != '') t1
                     SET t.VALUE = t1.VALUE
                   WHERE t.ID = t1.ID
                     AND t.NAME = t1.NAME
                  

                  这篇关于使用同一表中另一行的数据更新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 秒)

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

                      <tfoot id='5wslZ'></tfoot>
                            <bdo id='5wslZ'></bdo><ul id='5wslZ'></ul>

                            <small id='5wslZ'></small><noframes id='5wslZ'>