我试图在SQL查询中加入MS Access 2010中的三个表。

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;


我搜寻了网,据我所知应该是这样。我可以加入两个表没问题。我得到的错误是:“查询表达式中的语法错误(缺少运算符)”,它突出显示了两个INNER JOIN。

任何帮助将不胜感激。

最佳答案

首次加入时请添加括号(在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;

08-29 00:10