如何添加将链接SQL Server中两个不同表的列? [英] How do I add a column that will link two different tables in SQL server?

查看:143
本文介绍了如何添加将链接SQL Server中两个不同表的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试,其中我必须一起创建两个表,并且我将添加一个列,使用主键将这两个表链接在一起。我可以理解我可以使用join语句来执行此操作。唯一的问题是,如何添加一个列,我可以根据主键链接这两个表?



我尝试了什么:



我尝试使用连接语句,将两个表连接在一起但是在添加一个链接两个表的列时我遇到了问题一起使用他们的主键。

I have a test wherein I must create two tables together and that I will add a column that will link those two tables together using a primary key. I can understand that I can use join statements to do this. The only problem is that, how can I add a column wherein I can link those two tables based on their primary key?

What I have tried:

I tried having join statements, to join the two tables together but I am having the problem when it comes to adding a column that will link the two tables together using their primary keys.

推荐答案

调用链接:主键 - 外键关系 [ ^ ] 。



详情请见:

Bookshelf:主键 - 外键关系 [ ^ ]

创建主键| Microsoft Docs [ ^ ]

创建外键关系| Microsoft Docs [ ^ ]
That "link" is called: Primary Key - Foreign Key relationship[^].

For further details, please see:
Bookshelf: Primary Key-Foreign Key Relationships[^]
Create Primary Keys | Microsoft Docs[^]
Create Foreign Key Relationships | Microsoft Docs[^]


这篇关于如何添加将链接SQL Server中两个不同表的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆