SQL查询多对多关系问题
我正在学习 SQL,在构建查询时遇到问题,但找不到任何材料来解决这个问题。我将在专辑/曲目数据库中解释它。
所以这里是
,那是什么我想做:
我我确信答案是显而易见的,但这确实让我头疼。
Mariusz
(由 ypercube 编辑):
我的疯狂猜测是 OP 希望显示所有 Albums
和那些 Albums
的 Tracks
,no< /strong> 带有 'UnwantedTrackName'
的 Trackname
存在。
I am learning SQL and I have problem with building a query and I can't find any material to solve this. I will explain it on Album/Tracks database.
So here is
and that what I want to do:
I am sure answer is obvious but it really gives me a headache.
Mariusz
(EDIT by ypercube):
My wild guess is that OP wants to show all Albums
and Tracks
for those Albums
that no Trackname
with 'UnwantedTrackName'
exists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
Try this:
如果您在问题中包含代码和结果,而不是强迫我们重新输入它,对我们来说会容易得多。
您需要所有专辑和曲目,对于不包含某一特定曲目的所有专辑:
Would be a lot easier for us if you included your code and results in your question, rather than forcing us to re-type it.
You want all Albums and Tracks, for all Albums which don't include one particular track:
不太清楚你在问什么,但是“INNER JOIN”会给你你想要的吗?
It's not quite clear what you are asking, but will "INNER JOIN" give you what you want?
尝试对轨道表进行内部连接。如果这不起作用,请将 WHERE 条件推入 ON 子句 - 就像
Try INNER JOINing the tracks table. If that doesn't work, push the WHERE condition into the ON clause - like