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 - 从与常量合并的另一个表中插入数据

        MySQL - insert data from another table merged with constants(MySQL - 从与常量合并的另一个表中插入数据)

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

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

                  相关文档推荐

                  SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)
                  How to update a record using sequelize for node?(如何使用节点的 sequelize 更新记录?)
                  How to provide a mysql database connection in single file in nodejs(如何在 nodejs 中的单个文件中提供 mysql 数据库连接)
                  Looping Over Result Sets in MySQL(在 MySQL 中循环结果集)
                  SQL - Inserting a row and returning primary key(SQL - 插入一行并返回主键)
                  Python and SQLite: insert into table(Python 和 SQLite:插入表)
                  <legend id='c1FOw'><style id='c1FOw'><dir id='c1FOw'><q id='c1FOw'></q></dir></style></legend>
                    <bdo id='c1FOw'></bdo><ul id='c1FOw'></ul>

                      <tbody id='c1FOw'></tbody>
                    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'>