SELECT * FROM Questions
INNER JOIN QuestionKeyword INNER JOIN Keywords
ON Questions.ID=QuestionKeyword.QuestionID
AND QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
It says: Incorrect syntax near the keyword 'WHERE'.
SELECT * FROM Questions
INNER JOIN QuestionKeyword INNER JOIN Keywords
ON Questions.ID=QuestionKeyword.QuestionID
AND QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
It says: Incorrect syntax near the keyword 'WHERE'.
You cannot combine the conditions from multiple JOINs but you have to list them separately with each join:
SELECT * FROM Questions
INNER JOIN QuestionKeyword ON Questions.ID=QuestionKeyword.QuestionID
INNER JOIN Keywords ON QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
You've only got one ON clause and two INNER JOINs. For an INNER JOIN, join conditions with ON are mandatory. So the SQL parser is likely getting confused and seeing your WHEN unexpectedly.
You have two JOIN
s but only one ON
. You probably want
SELECT
*
FROM
Questions
INNER JOIN QuestionKeyword ON Questions.ID = QuestionKeyword.QuestionID
INNER JOIN Keywords ON QuestionKeyword.KeywordID = Keywords.ID
WHERE
Keywords.Keyword LIKE '%es%'
You're missing an "ON" after the first INNER JOIN.
SELECT *
FROM Questions
INNER JOIN QuestionKeyword
ON QuestionKeyword.QuestionID=Questions.ID
INNER JOIN Keywords
ON QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
You must have an ON
clause for each join you're doing. This should fix it:
SELECT * FROM Questions
INNER JOIN QuestionKeyword
ON Questions.ID=QuestionKeyword.QuestionID
INNER JOIN Keywords
ON QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
Edit: Damn, four other answers before I could finish typing! :P
Your INNER JOIN is messed up.
Something like this should work:
SELECT * FROM Questions
INNER JOIN QuestionKeyword ON Questions.ID=QuestionKeyword.QuestionID
INNER JOIN Keywords ON QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
Try rewriting it as:
SELECT *
FROM Questions
INNER JOIN QuestionKeyword ON Questions.ID=QuestionKeyword.QuestionID
INNER JOIN Keywords ON QuestionKeyword.KeywordID=Keywords.ID
WHERE Keywords.Keyword LIKE '%es%'
Each INNER JOIN requires a corresponding ON keyword and join condition.