<legend id='i2Xxl'><style id='i2Xxl'><dir id='i2Xxl'><q id='i2Xxl'></q></dir></style></legend>

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

  1. <tfoot id='i2Xxl'></tfoot>

      • <bdo id='i2Xxl'></bdo><ul id='i2Xxl'></ul>
    1. <i id='i2Xxl'><tr id='i2Xxl'><dt id='i2Xxl'><q id='i2Xxl'><span id='i2Xxl'><b id='i2Xxl'><form id='i2Xxl'><ins id='i2Xxl'></ins><ul id='i2Xxl'></ul><sub id='i2Xxl'></sub></form><legend id='i2Xxl'></legend><bdo id='i2Xxl'><pre id='i2Xxl'><center id='i2Xxl'></center></pre></bdo></b><th id='i2Xxl'></th></span></q></dt></tr></i><div id='i2Xxl'><tfoot id='i2Xxl'></tfoot><dl id='i2Xxl'><fieldset id='i2Xxl'></fieldset></dl></div>
    2. 如何使用加入从选择更新

      How to update from select with a Join(如何使用加入从选择更新)
    3. <legend id='7TE59'><style id='7TE59'><dir id='7TE59'><q id='7TE59'></q></dir></style></legend>
      <tfoot id='7TE59'></tfoot>

        1. <small id='7TE59'></small><noframes id='7TE59'>

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

                <tbody id='7TE59'></tbody>
                <bdo id='7TE59'></bdo><ul id='7TE59'></ul>
              • 本文介绍了如何使用加入从选择更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何更新也存在于子查询中的表?我必须分两个阶段完成吗?(创建一个临时表——将选中的数据放入其中,然后更新最终表)

                How can I update a table that is also present in a subquery? Do I have to do it in 2 stages? (create a temporary table - put the selected data in it and then update the final table)

                我正在尝试使用每个 CTN 的网络标签更新 invoiceLine 表.

                I am trying to update the invoiceLine table with the label of the network for each CTN.

                最终结果是:

                • 发票行

                ctn       network
                1234      network1
                2345      network2
                3456      network1
                

                我有以下表格:

                • 发票行

                ctn       network
                1234      null
                2345      null
                3456      null
                

              • 终端

              • terminal

                ctn       network
                1234      1
                2345      2
                3456      1
                

              • 网络

              • network

                id        label
                1         network1
                2         network2
                

              • 我可以运行一个选择,但我不知道如何通过加入进行更新:

                I can run a select but I'm not sure how to update with a join:

                update invoiceLine 
                inner join terminal on terminal.ctn = invoiceLine.ctn 
                set invoiceLine.network = 
                (
                  select network.label 
                  from invoiceLine 
                  inner join terminal on terminal.ctn = invoiceLine.ctn 
                  inner join network on network.id = terminal.network
                ) 
                where invoiceLine.ctn = terminal.ctn
                

                但是 MySQL 抛出一个

                but MySQL throws a

                错误代码:1093.您不能在 FROM 子句中指定要更新的目标表invoiceLine"

                Error Code: 1093. You can't specify target table 'invoiceLine' for update in FROM clause

                推荐答案

                UPDATE invoiceLine
                    INNER JOIN terminal
                        ON invoiceLine.ctn = terminal.ctn
                    INNER JOIN network
                        ON terminal.network = network.id
                    SET invoiceLine.network = network.label
                

                这篇关于如何使用加入从选择更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Building a comma separated list?(建立一个逗号分隔的列表?)
                Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)

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

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

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