[英]How to add values from one field in a table to another field in a different table using a common field?
[英]I want to add some fields from one table into another table by using one common field as the connector
我有一個表,我需要從中獲取一些字段,然后使用公共字段作為連接器將它們連接到另一個表中。
表格1
Bill No Name
1344 cb
1434 grer
32543 gg
1424 gwg
14545 gfg
表2
Bill No Age Address PhNumber
1344 12 xyz 2345
32543 16 xyz 8986
1434 14 xyz 5456
1424 17 xyz 9436
14545 21 xyz 9657
我想使用 BillNo 作為鏈接將表 2 中的字段 Age、Address 和 PhNumber 連接到 Table1。 所以我需要將這三個字段添加到 Table1 中,以糾正他的 BillNo。
需要的結果表:
表格1
Bill No Name Age Address PhNumber
1344 cb 12 xyz 2345
1434 grer 14 xyz 5456
32543 gg 16 xyz 8986
1424 gwg 17 xyz 9436
14545 gfg 21 xyz 9657
使用連接:
select t1.bill_no, Name, Age, Address, PhNumber
from table1 t1
join table2 t2 on t2.bill_no = t1.bill_no
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.