• <small id='WYO1O'></small><noframes id='WYO1O'>

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

      1. 根据条件用另一个表的列更新列值

        update columns values with column of another table based on condition(根据条件用另一个表的列更新列值)
          <tfoot id='Rd9Xv'></tfoot>

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

                    <tbody id='Rd9Xv'></tbody>

                  <legend id='Rd9Xv'><style id='Rd9Xv'><dir id='Rd9Xv'><q id='Rd9Xv'></q></dir></style></legend>
                2. 本文介绍了根据条件用另一个表的列更新列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有两张桌子...

                  table1 ( id, item, price ) 值:

                  table1 ( id, item, price ) values:

                  id | item | price
                  -------------
                  10 | book | 20  
                  20 | copy | 30   
                  30 | pen  | 10
                  

                  ....table2 ( id, item, price) 值:

                  ....table2 ( id, item, price) values:

                  id | item | price
                  -------------
                  10 | book | 20
                  20 | book | 30
                  

                  现在我想:

                  update table1 
                     set table1.Price = table2.price 
                   where table1.id = table2.id
                     and table1.item = table2.item.
                  

                  我该怎么做?

                  推荐答案

                  应该这样做:

                  UPDATE table1 
                     SET table1.Price = table2.price 
                     FROM table1  INNER JOIN  table2 ON table1.id = table2.id
                  

                  你也可以试试这个:

                  UPDATE table1 
                     SET price=(SELECT price FROM table2 WHERE table1.id=table2.id);
                  

                  这篇关于根据条件用另一个表的列更新列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Bogus foreign key constraint fail(虚假外键约束失败)
                  how to get last insert id after insert query in codeigniter active record(如何在codeigniter活动记录中插入查询后获取最后一个插入ID)
                  Force InnoDB to recheck foreign keys on a table/tables?(强制 InnoDB 重新检查表/表上的外键?)
                  How to auto generate migrations with Sequelize CLI from Sequelize models?(如何使用 Sequelize CLI 从 Sequelize 模型自动生成迁移?)
                  Clear MySQL query cache without restarting server(无需重启服务器即可清除 MySQL 查询缓存)
                  ALTER TABLE to add a composite primary key(ALTER TABLE 添加复合主键)
                  <i id='qrRkR'><tr id='qrRkR'><dt id='qrRkR'><q id='qrRkR'><span id='qrRkR'><b id='qrRkR'><form id='qrRkR'><ins id='qrRkR'></ins><ul id='qrRkR'></ul><sub id='qrRkR'></sub></form><legend id='qrRkR'></legend><bdo id='qrRkR'><pre id='qrRkR'><center id='qrRkR'></center></pre></bdo></b><th id='qrRkR'></th></span></q></dt></tr></i><div id='qrRkR'><tfoot id='qrRkR'></tfoot><dl id='qrRkR'><fieldset id='qrRkR'></fieldset></dl></div>

                          <tbody id='qrRkR'></tbody>

                            <bdo id='qrRkR'></bdo><ul id='qrRkR'></ul>
                            <tfoot id='qrRkR'></tfoot>

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

                          • <legend id='qrRkR'><style id='qrRkR'><dir id='qrRkR'><q id='qrRkR'></q></dir></style></legend>