sql中的主键问题 [英] Primary key problem in sql

查看:48
本文介绍了sql中的主键问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个表主键中的列和另一个表中具有相同数据类型主键的另一列是否可能?还要提到我将加入两个表

Is it possible that a column in one table primary key and the other column in another table with same datatype primary key? It is also mention that I will join two table

推荐答案

是的,为什么不呢。这就是外键的概念[ ^ ]。



另一列将是另一个表中的主键,将是在第一个表中引用为外键。



参考 - SQL FOREIGN KEY Constraint [ ^ ]。



因此,您可以加入该列。

Yes why not. That is the concept of Foreign Key[^].

The other column will be primary key in the other table and will be referenced in the first table as Foreign key.

Refer - SQL FOREIGN KEY Constraint[^].

So, depending on that column you can join.
SELECT columnName
FROM 
Table1
INNER JOIN
Table2
ON Table1.Column1 = Table2.Column1
-- (Add some condition if you want using WHERE)


是的,如果您有任何问题,请写下您的查询。
yes, It is possible if you have any problem please write your query.


这篇关于sql中的主键问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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