简体   繁体   English

如何在其值来自另一个表的位置插入新列?

[英]How can I insert new column where its value coming from another table?

I have 2 different table (Table A and Table B).我有 2 个不同的表(表 A 和表 B)。

Table A looks like this: enter image description here表 A 看起来像这样:在此处输入图像描述

Table B looks like this: enter image description here表 B 如下所示:在此处输入图像描述

I want to insert new column referred to productname in Table A, which its value based on productname in Table B.我想在表 A 中插入引用 productname 的新列,其值基于表 B 中的 productname。

How I can write the syntax?我如何编写语法?

I think what you need is to join the tables like this:我认为您需要的是像这样加入表格:

Select A.userid,
       A.itemid,
       A.insurance_amount,
       A.productid,
       B.productname
From A
Join B ON B.productid = A.productid

暂无
暂无

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

相关问题 如何:插入值在另一个表上的列中 - How To: Insert into column where the value is on another table 如何按特定列值将记录从表插入到另一个表顺序? - How can I insert records from a table to another table order by the specific column value? 根据另一列的值将值插入新表的列中 - Insert value into column in new table based on value from another column SQL:如何创建一个新列,其值引用另一个表中的另一个列? - SQL: How do create a new column and its value is referencing another column from another table? 当某个列的值与另一张表中的值相等时,如何对行求和并将它们插入到第三张表中? - How can i sum rows when a certain column value are equal from another table and insert them to a third table? 我如何插入到table1中,其中table2.column = value? - How can i insert into Table1 where table2.column = value? 如何将另一个选择的结果插入到添加了额外列值的新表中? - How to insert results from another select into new table with extra column value added? 如何在列包含特殊字符的表中插入值? - How can I insert a value into a table where the column contains special character? 如何将值与其他列一起插入指定列中,而不会单独将其显示在新的另一行中? - How can I insert a value in a specified column together with the other columns without appearing it into a new another row alone? 如何将一个表中的列及其值添加到 SQL 中的另一个表中? - How can I add a column with its values from one table into another table in SQL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM