开发者

SQL Inner join error

SELECT CommitTime 
FROM Logs 
(INNER JOIN SecurityOptions 
    ON SecurityOptions.Name=Logs.SecurityOption) 
WHERE SecurityOption.ID=22

This is the sql string I use to grab data from the DB and the ODBC Bridge gives me the nex开发者_JAVA百科t error [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

And if it doesn't give me this error it gives me that INNER JOIN isn't supported and sometimes Syntax Error

Am I doing something wrong?


I think it is because of the parenthesis. This part (INNER JOIN SecurityOptions ON SecurityOptions.Name=Logs.SecurityOption) is being evaluated to an unaliased table, which is causing your issue.

Removing the parenthesis should fix it:

SELECT CommitTime 
FROM Logs L
INNER JOIN SecurityOptions SO
    ON SO.Name = L.SecurityOption
WHERE SO.ID=22

Edit:

However, from the names of the columns, it does not seem to me like the JOIN is a valid one. Usually the join is based on Ids - therefore, it could be something like SO.Id = Logs.SecurityOptionId.

I think you should use the query designer in MS Access - just pull the tables in and if there are relationships defined, they will show up right away. If they do not show up, then you would have to look at the INSERTs to figure out how these two tables are related to each other.


INNER JOIN is NOT the same as FULL JOIN. DON'T Try FULL JOIN>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜