SQL多对多复合键链接表连接
我希望这不是一个重复的问题,但我有三个表试图从中提取信息。
我的表的架构如下所示:
计算机
ComputerID (PK) 创建日期时间 友好名称 计算机
名称 事件条目
事件条目 ID EventEntrySource(这两个构成 PK)
Link_Computers_EventEntries
EventEntryID EventEntrySource ComputerID
我想要做的就是拉取事件条目列表——它们的 EventEntryID 和 EventEntryID。链接表中的 EventEntrySource 取决于我的查询指定的 ComputerID。
我相信这应该很简单,但我不是 SQL 专家。
我正在使用 SQL Server 2008 R2 Express。
I hope this is not a duplicate of a question, but I have three tables I'm trying to pull information from.
My table's schemas look like so:
Computers
ComputerID (PK)
CreatedDateTime
FriendlyName
ComputerName
EventEntries
EventEntryID
EventEntrySource (These two form the PK)
Link_Computers_EventEntries
EventEntryID EventEntrySource ComputerID
All I want to do is pull a list of event entries--their EventEntryID & EventEntrySource from the link table depending on which ComputerID my query specifies.
I believe this should be simple but I am not a SQL expert.
I am using SQL Server 2008 R2 Express.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下查询产生预期结果:
The following query produces the intended result: