如何将这三个表连接到所绘制的条件
select Name
from Artist
INNER JOIN Track ON Artist.aID = Track.aID
INNER JOIN CD ON CD.cID = Track.cID
where CD.Title = 'Compilation '
但是,为什么输出的是Artist.Table中的全名?
我不认为您的查询返回所有艺术家姓名;但是,您可能在结果集中多次重复使用相同的艺术家姓名。
为避免这种情况,您可以使用exists
而不是联接:
select a.name
from artist a
where exists (
select 1
from track t on
inner join cd c on c.cid = t.cid
where a.aid = t.aid and c.title = 'compilation'
)