Reputation: 169
I need to find the names of all my salespeople that represent a paticular band in my Artists Table.
My Tables resmeble the following:
SalesID, Firstname, Lastname
ArtistID, ArtistName
MembersID, Firstname, Lastname. SalesID
The MembersID and Artists tables are related by the following table:
ArtistID, MemberID
I formulated the following query:
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";
Is their also a way to do this with subqueries?
Upvotes: 0
Views: 91
Reputation: 853
Try this:
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"
Upvotes: 1
Reputation: 109
shouldn't your inner join to artists have an on
clause then your where
clause?
inner join artists a where a.artistname = "The Bullets";
would be
inner join artists a on a.artistid = x.artistid
where artists.artistname = "The Bullets";
Upvotes: 0