1. <legend id='dEepB'><style id='dEepB'><dir id='dEepB'><q id='dEepB'></q></dir></style></legend>

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

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

        MySQL - 从与常量合并的另一个表中插入数据

        时间:2023-10-08

              <tbody id='Ma6Ac'></tbody>

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

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

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

                  本文介绍了MySQL - 从与常量合并的另一个表中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含一些数据的临时表 (products_temp),我还有另一个表(产品)需要插入数据.我需要在新记录上手动设置一些常量,例如 vendor_id=1 等...

                  I have a temporary table (products_temp) with some data, and I have another table (products) I need to insert the data into. I have some constants I need to set manually on new records, like vendor_id=1, etc...

                  是否可以在一个请求中插入临时表数据和常量?

                  Is it possible to do the insertion with the temporary table data and the constants in one request?

                  temp_products:

                  temp_products:

                  product_name | product_desc | category_name | mf_name ...
                  

                  产品(category_name,mf_name 不在):

                  products (category_name, mf_name is not in):

                  product_id | product_name | product_desc | vendor_id | distributor_id ...
                  

                  常量:

                  vendor_id=1, distributor_id=2
                  

                  推荐答案

                  使用 INSERT ... SELECT 语句,您在其中选择常量值以及来自 products_temp 的数据:

                  Use an INSERT ... SELECT statement where you are selecting constant values as well as data from products_temp:

                  INSERT INTO products (product_data, vendor_id)
                      SELECT data, '1' FROM products_temp
                  

                  这篇关于MySQL - 从与常量合并的另一个表中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:添加“字段"从 UNION 到 SQL 结果的表名? 下一篇:如何在 SQL 中将 varchar 列拆分为多个值?

                  相关文章

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

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

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