<bdo id='BojKC'></bdo><ul id='BojKC'></ul>
    <tfoot id='BojKC'></tfoot>
    <legend id='BojKC'><style id='BojKC'><dir id='BojKC'><q id='BojKC'></q></dir></style></legend>
  1. <small id='BojKC'></small><noframes id='BojKC'>

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

    1. 如何在 MySQL 的“插入"语句中使用“选择"

      How to use #39;select #39; in MySQL #39;insert#39; statement(如何在 MySQL 的“插入语句中使用“选择)

          • <bdo id='RTfyv'></bdo><ul id='RTfyv'></ul>
          • <small id='RTfyv'></small><noframes id='RTfyv'>

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

                本文介绍了如何在 MySQL 的“插入"语句中使用“选择"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试向需要从另一个表中检索值的表中插入额外的行.下面是一个示例查询:

                I'm trying to insert additional rows into a table which requires a value to be retrieved from another table. Below is an example query:

                insert into a.grades (rollno, grade)
                values(select rollno from b.students where ssn=12345, 'A');
                

                b.students 表的结构是rollno, ssn, name.

                我知道上面的查询是错误的.有没有办法在插入行时从其他表中检索 1 个值?

                I knew the above query is wrong. Is there a way to retrieve 1 value from other table while inserting a row?

                推荐答案

                INSERT INTO a.grades (rollno, grade)
                    SELECT rollno, 'A' FROM b.students WHERE ssn = 12345;
                

                某些 DBMS 会接受以下内容,并在 SELECT 语句周围加上一组额外的括号:

                Some DBMS would accept the following, with an extra set of parenthesis around the SELECT statement:

                INSERT INTO a.grades (rollno, grade)
                   VALUES((SELECT rollno FROM b.students WHERE ssn = 12345), 'A');
                

                这篇关于如何在 MySQL 的“插入"语句中使用“选择"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
                    <tbody id='qW6tS'></tbody>
                  <legend id='qW6tS'><style id='qW6tS'><dir id='qW6tS'><q id='qW6tS'></q></dir></style></legend>

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

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