SQL多对多复合键链接表连接

发布于 2024-12-28 02:52:20 字数 436 浏览 0 评论 0原文

我希望这不是一个重复的问题,但我有三个表试图从中提取信息。

我的表的架构如下所示:

计算机

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葵雨 2025-01-04 02:52:20

以下查询产生预期结果:

SELECT EventEntryID, EventEntrySource 
FROM Link_Computers_EventEntries
WHERE ComputerID=1 -- Where 1 represents the "specified" ComputerID value

The following query produces the intended result:

SELECT EventEntryID, EventEntrySource 
FROM Link_Computers_EventEntries
WHERE ComputerID=1 -- Where 1 represents the "specified" ComputerID value
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文