Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access 2010: Joining three tables, unknown error

Tags:

sql

ms-access

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.

like image 981
Juicy Avatar asked Mar 17 '13 14:03

Juicy


1 Answers

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;
like image 164
John Woo Avatar answered Sep 24 '22 13:09

John Woo