<small id='2x56Q'></small><noframes id='2x56Q'>

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

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

        • <bdo id='2x56Q'></bdo><ul id='2x56Q'></ul>
      1. MYSQL INSERT SELECT 问题

        时间:2023-10-08
      2. <legend id='njEvH'><style id='njEvH'><dir id='njEvH'><q id='njEvH'></q></dir></style></legend>

        <tfoot id='njEvH'></tfoot>

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

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

                  问题描述

                  我在理解如何执行某些 INSERT SELECT 方面有点困难.

                  i have a little difficulty in understanding how to do some INSERT SELECT.

                  例如我有两张桌子.

                  TABLE : users  
                  
                   id | name   | gender  
                   1  | John   | m  
                   2  | Mary   | f  
                  
                  TABLE : website  
                  
                   fid | url             | id  
                   1   | www.desilva.biz | 2  
                   2   | gidhelp.com     | 4  
                  

                  现在假设我想向表格网站添加另一个查询.我得到两个变量,让我们说:

                  Now let's say i want to add another query to the table website. I get two variables, lets say:

                  $user = John;
                  $site = "www.google.com";
                  

                  我想从 users 表中选择 John 的 id 并在一个语句中将其插入到 website 表中.

                  i want to select the id of John from users table and insert it into website table in one statement.

                  我该怎么做?

                  推荐答案

                  假设你的变量已经被正确转义并且不受SQL注入的影响:

                  Assuming your variables are already escaped properly and are not subject to SQL injection:

                  INSERT
                  INTO    website (url, fid)
                  SELECT  $site, id
                  FROM    users
                  WHERE   name = $user
                  

                  这篇关于MYSQL INSERT SELECT 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL - 如何使用 concat 和 group_concat 将行值显示为列名 下一篇:具有默认关系的左连接

                  相关文章

                    • <bdo id='iVLH6'></bdo><ul id='iVLH6'></ul>
                  1. <tfoot id='iVLH6'></tfoot>

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

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

                      <legend id='iVLH6'><style id='iVLH6'><dir id='iVLH6'><q id='iVLH6'></q></dir></style></legend>