简体   繁体   English

有没有办法根据一个表的 ID 为其他表提供 ID?

[英]Is there a way to give ID to other tables based on an ID with one table?

I have two tables as following:我有两个表如下:

ID ID Name名称 Age年龄
1 1个 aaa啊啊 23 23
2 2个 bbb bbb 21 21
3 3个 ccc抄送 25 25
4 4个 ddd DDD 20 20
ID ID Name名称 Age年龄 Phone电话
aaa啊啊 23 23 0000 0000
bbb bbb 21 21 1111 1111
ccc抄送 28 28 2222 2222
ddd DDD 29 29 3333 3333

The first table name as T1 include ID that I gave them unique ID, however from the second table T2 the ID column is empty.作为 T1 的第一个表名包括我给它们唯一 ID 的 ID,但是在第二个表 T2 中,ID 列是空的。 How can I add the same ID to the second table T2?如何将相同的 ID 添加到第二个表 T2? Note: The order of the names is different, and I have about 3000 records.注意:名字顺序不一样,我大概有3000条记录。 Can anyone help me how to do that by Microsoft Excel or Access or by programming language python?任何人都可以通过 Microsoft Excel 或 Access 或编程语言 python 帮助我如何做到这一点?

Regards,问候,

Try with an update query having a subquery:尝试使用具有子查询的更新查询:

Update T2
Set T2.ID = 
    (Select Top 1 T1.Id 
    From T1
    Where T1.Name = T2.Name)

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

相关问题 根据ID给数据框评分 - Give scores to dataframe based on id flask 根据其他表的id添加新行 - flask add a new row based on id of other tables 在 ID 上连接两个表,其中表一有重复而表二没有 - Join two tables on ID where table one has duplicates and table two does not 根据python中的其他列生成自定义ID - Generating a custom ID based on other columns in python 根据其他表格在python中创建或填充表格 - Create or populate a table in python based on other tables Python-通过从B表中选择ID来更新一个表中多个记录的最快方法 - Python - Fastest way to update multiple records in one table by selecting id from B table 根据一张表中的纬度和经度是否存在于另一张表的多边形中来连接两张表(来自不同的数据库) - Joining two tables (from different databases) based on whether lat and long from one table are present in the polygon of the other 如果 ID 不在 DWH 表中,则使用其他表中的值填充表 - Populating Table with Values from other table if ID not in DWH table 根据 ID 连接两个表中的列 - SQLite - Joining columns from two tables based on ID - SQLite 根据另一个表fastAPI和sqlalchemy的Id从表中取数据 - Fetching data from the table based on the Id of another table fastAPI and sqlalchemy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM