mysql查询中的语法错误(缺少运算符)

时间:2017-09-01 04:53:13

标签: mysql excel vba

我正在开发一个项目,我需要将查询的记录集导出到Excel文件。我让Excel导出部分正常工作。但我在查询时遇到了一些麻烦。

Private Sub Tch_rep_Click()
Dim strSQL As String
Dim qdf As DAO.QueryDef

strSQL = "SELECT tbl_tch.teacher_id,teacherfirstname_vchr,teachersurname_vchr,description_vchr,teacheremail_vchr FROM tbl_tch " & _
"LEFT JOIN tbl_tchcareer ON tbl_tch.teacher_id = tbl_tchcareer.teacher_id " & _
"LEFT JOIN tbl_typedescription ON tbl_tchcareer.tchspecialism_int = tbl_typedescription.description_int " & _
"AND tbl_typedescription.descriptiongroup_int = 6 " & _
"ORDER BY tbl_tch.teacher_id DESC"

Set qdf = CurrentDb.CreateQueryDef("TeacherRecords", strSQL)

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "TeacherRecords", "K:\Records\Teachers\Teacher Records.xls", True

CurrentDb.QueryDefs.Delete qdf.Name

qdf.Close
End Sub

我收到以下错误消息。

  

查询表达式中的语法错误(缺少运算符)   'tbl_tch.teacher_id = tbl_tchcareer.teacher_id左连接   tbl_typedescription on   tbl_tchcareer.tchspecialism_int = tbl_typedescription.description_int

当我使用像“select * from tablename”这样的简单查询时,一切正常。

该查询在mysql控制台中有效。

0 个答案:

没有答案