• <tfoot id='XmoSu'></tfoot><legend id='XmoSu'><style id='XmoSu'><dir id='XmoSu'><q id='XmoSu'></q></dir></style></legend>

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

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

          <bdo id='XmoSu'></bdo><ul id='XmoSu'></ul>
      1. 使用 SELECT 插入

        时间:2023-08-18

            <tfoot id='fg499'></tfoot>

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

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

                  <bdo id='fg499'></bdo><ul id='fg499'></ul>
                  本文介绍了使用 SELECT 插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个使用 SELECT 语句插入的查询:

                  I have a query that inserts using a SELECT statement:

                  INSERT INTO courses (name, location, gid) 
                  SELECT name, location, gid 
                  FROM courses 
                  WHERE cid = $cid
                  

                  是否可以只选择名称、位置"?用于插入,并将 gid 设置为查询中的其他内容?

                  Is it possible to only select "name, location" for the insert, and set gid to something else in the query?

                  推荐答案

                  是的,绝对可以,但请检查您的语法.

                  Yes, absolutely, but check your syntax.

                  INSERT INTO courses (name, location, gid)
                  SELECT name, location, 1
                  FROM   courses
                  WHERE  cid = 2
                  

                  当然,您可以在其位置放置一个与 gid 类型相同的常量,而不仅仅是 1.而且,我只是编造了 cid 值.

                  You can put a constant of the same type as gid in its place, not just 1, of course. And, I just made up the cid value.

                  这篇关于使用 SELECT 插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何判断 MySQL 表的上次更新时间? 下一篇:如何在 MySQL 中执行分组排名

                  相关文章

                  最新文章

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

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

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