Joining 3 tables into 1 - SQL
I'm trying to LEFT OUTER JOIN two tables and then INNER JOIN another table together in Access 2007.
SELECT RestaurantName,
StreetAddress,
City,
State,
Zip,
RestaurantWebsite,
MenuLink,
RestaurantTimes,
PhoneNumber,
PictureTit开发者_运维知识库le,
PictureTitle3,
PictureTitle3,
PictureTitle4,
PictureTitle,
TagType
FROM Restaurants r
LEFT OUTER JOIN RestaurantPictures rp ON r.ID = rp.ID
INNER JOIN RestaurantTag rt ON r.TagID = t.TagID
I keep getting a Syntax Error in my query expression. "INNER JOIN RestaurantTag rt ON rt.TagID = r.TagID"
I have a Corresponding TagID in both the Restaurant and RestaurantTag tables. I can't seem figure out why I'm getting this error.I can successfully JOIN the first two tables but the third table is the one giving me trouble. Any suggestions would be greatly appreciated!
Without seeing a table definition this is a guess, but you have an error:
INNER JOIN RestaurantTag rt ON r.TagID = t.TagID
should be INNER JOIN RestaurantTag rt ON r.TagID = rt.TagID
Try to put the join expression in ()
(Restaurants r LEFT OUTER JOIN RestaurantPictures rp ON r.ID = rp.ID)
INNER JOIN RestaurantTag rt ON r.TagID = t.TagID
SELECT
RestaurantName, StreetAddress, City, State, Zip, RestaurantWebsite,
MenuLink, RestaurantTimes, PhoneNumber, PictureTitle, PictureTitle3,
PictureTitle3, PictureTitle4, PictureTitle, TagType
FROM
Restaurants r LEFT OUTER JOIN RestaurantPictures rp ON r.ID = rp.ID
INNER JOIN RestaurantTag rt ON r.TagID = rt.TagID
精彩评论