简体   繁体   English

INSERT INTO SELECT 语句包含更多不在另一个表中的列

[英]INSERT INTO SELECT statement with more columns which is not in another table

Actually i have 2 tables Table A and Table B其实我有2张桌子A表和B表

Table A have 3 Columns such as A_a, A_b and A_c表 A 有 3 列,例如 A_a、A_b 和 A_c

Table B have 5 Columns such as B_a, B_b, B_c, B_d and B_e.表 B 有 5 列,例如 B_a、B_b、B_c、B_d 和 B_e。

Here i Want to add First 3 column of Table B from Table A and Last 2 Column should be filled by Form.在这里,我想从表 A 中添加表 B 的前 3 列,最后 2 列应由表格填写。

So how it is possible.那怎么可能。

I have tried INSERT INTO SELECT but for Last 2 Columns我试过 INSERT INTO SELECT 但对于最后 2 列

You could use default filler您可以使用默认填充物

  INSERT INTO TABLEB(col1, col2, col3, col4, col5) 
  SELECT col1, col2, col3, '', ''
  FROM TABLEA;

Now, instead of '' you could pass any variable, which you get from application side.现在,您可以传递从应用程序端获得的任何变量,而不是''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM