5
votes

I am trying to join three tables in MS Access 2010 in a SQL query.

SELECT Track.trackName, TrackIsGenre.genre, ContainsTracks.albums
FROM Track 
INNER JOIN TrackIsGenre ON  Track.trackName = TrackIsGenre.track
INNER JOIN ConstainsTracks ON Track.trackName = ContainsTracks.tracks
WHERE genre = "Rock"
ORDER BY trackName ASC;

I searched the net and as far as I can see this should be it. I can JOIN two tables no problem. The error I get is: "Syntax error (missing operator) in query expression" and it highlights the two INNER JOIN.

Any help would be greatly appreciated.

1

1 Answers

5
votes

Add a parenthesis on you first join, (this is optional on MOST RDBMS)

SELECT  Track.trackName, TrackIsGenre.genre, ContainsTracks.albums
FROM    (Track INNER JOIN TrackIsGenre ON  Track.trackName = TrackIsGenre.track)
        INNER JOIN ConstainsTracks ON Track.trackName = ContainsTracks.tracks
WHERE   genre = "Rock"
ORDER   BY trackName ASC;