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

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

    1. <tfoot id='PHTJD'></tfoot>
      1. Mysql插入2个表

        Mysql insert into 2 tables(Mysql插入2个表)
        • <small id='8odci'></small><noframes id='8odci'>

          <legend id='8odci'><style id='8odci'><dir id='8odci'><q id='8odci'></q></dir></style></legend>

        • <i id='8odci'><tr id='8odci'><dt id='8odci'><q id='8odci'><span id='8odci'><b id='8odci'><form id='8odci'><ins id='8odci'></ins><ul id='8odci'></ul><sub id='8odci'></sub></form><legend id='8odci'></legend><bdo id='8odci'><pre id='8odci'><center id='8odci'></center></pre></bdo></b><th id='8odci'></th></span></q></dt></tr></i><div id='8odci'><tfoot id='8odci'></tfoot><dl id='8odci'><fieldset id='8odci'></fieldset></dl></div>
              <tbody id='8odci'></tbody>
              <bdo id='8odci'></bdo><ul id='8odci'></ul>
              • <tfoot id='8odci'></tfoot>
                  本文介绍了Mysql插入2个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想插入两个表

                  访问:

                  visit_id int | card_id int
                  

                  注册:

                  registration_id int | type enum('in','out') | timestamp int | visit_id  int
                  

                  我想要类似的东西:

                  INSERT INTO `visits` as v ,`registration` as v
                  (v.`visit_id`,v.`card_id`,r.`registration_id`, r.`type`, r.`timestamp`, r.`visit_id`) 
                  VALUES (NULL, 12131141,NULL, UNIX_TIMESTAMP(), v.`visit_id`);
                  

                  不知道有没有可能

                  推荐答案

                  一个查询是不可能的,因为INSERT只能向mysql中的一张表插入数据.你可以

                  It's not possible with one query as INSERT can only insert data to one table in mysql. You can either

                  1. 将其编写为两个查询并作为批处理执行
                  2. 创建一个将执行两个插入命令的存储过程

                  如果您需要确保两个查询都会写入数据,您可以将这些插入内容包装在事务中.

                  You can wrap those inserts in transaction if you need to make sure that both queries will write the data.

                  这篇关于Mysql插入2个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
                  MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
                  Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
                  How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
                  Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
                  Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)

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

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

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

                            <tfoot id='a5krD'></tfoot>