我需要在我的艺术家表中找到代表特定乐队的所有销售人员的姓名。
我的表格重申了以下内容:
SalesID,名字,姓氏
ArtistID,ArtistName
MembersID,名字,姓氏。 SalesID
MembersID和Artists表与下表相关:
ArtistID,MemberID
我制定了以下查询:
select sp.firstname, sp.lastname from salespeople sp
inner join members m on (m.salesid = sp.salesid)
inner join xrefartistsmembers x on (x.memberid = m.memberid)
inner join artists a where a.artistname = "The Bullets";
他们也是用子查询做这个的方法吗?
答案 0 :(得分:1)
试试这个:
select sp.firstname, sp.lastname from salespeople sp
inner join members m on (m.salesid = sp.salesid)
inner join xrefartistsmembers x on (x.memberid = m.memberid)
inner join artists a on a.artistID = x.artistID
where a.artistname = "The Bullets"
答案 1 :(得分:0)
你对艺术家的内部联系不应该有on
条款,而不是你的where
条款吗?
inner join artists a where a.artistname = "The Bullets";
将是
inner join artists a on a.artistid = x.artistid
where artists.artistname = "The Bullets";