三个表的 SQL 查询问题
我有三个表,我想从第一个表中选择两列,从最后一个表中选择一列,以显示在 asp.net 的 gridview 中,
所以我有一个表 Sprint、Task 和 Blocked。
我想显示阻止表中的 CurrentStatus,为此我需要使用任务表将它们连接在一起。我尝试了下面的查询,但它不起作用。
谁能帮我解决这个问题,我将不胜感激。
谢谢
I've got three tables, I want to select two columns from the first table and one from the last table to be displayed in a gridview for asp.net
So I have a table Sprint, Task and Blocked.
I want to display CurrentStatus from blocked table and to do this I need to use the Task table to join them together. I've attempted the query below but it doesn't work.
Can anyone help me on this please, it would be appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您现在执行此操作的方式是,
基本上,您需要先 INNER JOIN Task 和 Blocked,然后 RIGHT JOIN 到 Sprint(获取所有 Sprint):
或者,如果这对您来说更容易理解,您可以这样写: You LEFT将 Sprint 连接到已经组合的任务阻止数据。
The way that you are doing it now, you are doing
Basically, you need to INNER JOIN Task and Blocked first, then RIGHT JOIN to Sprint (which gets all Sprints):
Alternatively, if that's easier to understand for you, you can write it like this: You LEFT JOIN Sprint to the already combined Task-Blocked data.
那么 RPM 是正确的。我刚刚测试了它,你需要两个 LEFT JOIN 。
Well RPM is right. I just tested it, and you need two
LEFT JOIN
s.我想我只是展示 RPM1984 和 Jordan 在这里所说的话,我认为他们是正确的:
试试这个:
I think I'm just showing what RPM1984 and Jordan are saying here and I think they're correct:
Try this: