当我的 SQL 语句中只有一个内连接时,它工作得很好。我尝试连接第二个表,现在我收到一条错误消息,提示存在语法错误(缺少运算符)。这是什么情况?
当我的 SQL 语句中只有一个内连接时,它运行得很好。我尝试连接第二个表,现在收到一条错误消息,提示存在语法错误(缺少运算符)。这是怎么回事?
adsFormView.SelectCommand = "SELECT * FROM [tableCourse] INNER JOIN [tableGrade] ON [tableCourse].[grading] = [tableGrade].[id] INNER JOIN [tableCourseType] ON [tableCourse].[course_type] = [tableCourseType].[id] WHERE [prefix]='" & myPrefix & "' AND [course_number]='" & myCourseNum & "'"
MS Access(特别是 Jet/ACE)要求在多个连接中使用括号。请尝试:
adsFormView.SelectCommand = _
" SELECT * FROM ([tableCourse] " & _
" INNER JOIN [tableGrade] " & _
" ON [tableCourse].[grading] = [tableGrade].[id]) " & _
" INNER JOIN [tableCourseType] " & _
" ON [tableCourse].[course_type] = [tableCourseType].[id] " & _
" WHERE [prefix]='" & myPrefix & "'" & _
" AND [course_number]='" & myCourseNum & "'"