首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >SQL Server,连接到多个具有相同列的表

SQL Server,连接到多个具有相同列的表
EN

Stack Overflow用户
提问于 2019-02-28 03:01:25
回答 2查看 47关注 0票数 1

使用SQL server,我有一个表,它可以与使用同一列的多个表联接。该表有两列: SourceType和SourceID。SourceType是要连接的表,SourceID是我们连接到的表的主键。这会产生如下查询:

select * 
from MyTable join TableOne
where MyTable.SourceId = TableOne.ID
   and MyTable.SourceType = 'TableOne';

select * 
from MyTable join TableTwo
where MyTable.SourceId = TableOne.ID
   and MyTable.SourceType = 'TableTwo';

我需要对此做一些研究。这种方法叫什么?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54912697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档