我是一個MySQL新手,無法弄清楚這裏出了什麼問題。我有兩張桌子。左表稱爲「鍛鍊」。相關列爲date
(類型日期)和id
(類型爲int)。MySQL內部連接查詢語法錯誤
右表名爲Workout_locations
(相關字段:workout_id type int, and location_id type int
)。
連接字段是Workouts.id
和Workout_locations.workout_id
。
我想要做的是得到兩列的表:date
(來自Workouts)和location_id
(來自Workout_locations
)。我只需要根據幾個字段從Workouts
表中提取記錄(sql語句應該清楚這一點)。
這裏是我的SQL語法:
SELECT Workouts.date as date, Workout_locations.location_id as loc_id
FROM Workouts
WHERE Workouts.pacegroup_id='9' AND (Workouts.date BETWEEN '2013-08-19' AND '2013-08-25')
INNER JOIN Workout_locations ON Workouts.id=Workout_locations.workout_id"
但我得到這個錯誤:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN Workout_locations ON Workouts.id=Workout_locations.workout_id' at line 1
我希望這是一個非常簡單的錯誤發現有人誰是經歷了這。任何人都可以看到它?謝謝!
這似乎解決它。是的,這些parens主要是爲了我自己的理智。謝謝! – Alex