我无法弄清楚这种SQL语法有什么问题。我正在使用MySQL 3.3.1
所有这些空字段都是varchar或text。 这么多空字段的原因是由于UI要求,我想插入只包含基本信息的记录,然后再填充详细信息。
INSERT INTO projtrackingoppor(address,latLong,stage,projType,dateInitiated,designProjNumber,constrProjNumber,designProjManager,clientContact,client,notes,nextAction,dueDate,designCriteria,designBearingCapacity,designGroundMotion_SLS,allowableSettlement_SLS,allowableLateralDisplacement_SLS,designGroundMotion_ULS,allowableSettlement_ULS,allowableLateralDisplacement_ULS,otherDeisgnCriteria,siteDescription,subsurfaceConditions,as-BuiltImprovementType_1,as-BuiltDiameter_1,as-BuiltDepth_1,as-BuiltSpacing_1,as-BuiltPrice_1,commentsOnPrice_1,proposedImprovementType_2,proposedDiameter_2,proposedDepth_2,proposedSpacing_2,proposedPrice_2,commentsOnPrice_2,proposedImprovementType_3,proposedDiameter_3,proposedDepth_3,proposedSpacing_3,proposedPrice_3,commentsOnPrice_3,proposedImprovementType_4,proposedDiameter_4,proposedDepth_4,proposedSpacing_4,proposedPrice_4,commentsOnPrice_4,proposedImprovementType_5,proposedDiameter_5,proposedDepth_5,proposedSpacing_5,proposedPrice_5,commentsOnPrice_5,soilDescription_a,Ic_a,midlayerDepth_a,finesContent_a,WC_a,LL_a,PI_a,PRE_qtncs_N160cs_a,POST_qtncs_N160cs_a,comments_a,soilDescription_b,Ic_b,midlayerDepth_b,finesContent_b,WC_b,LL_b,PI_b,PRE_qtncs_N160cs_b,POST_qtncs_N160cs_b,comments_b,soilDescription_c,Ic_c,midlayerDepth_c,finesContent_c,WC_c,LL_c,PI_c,PRE_qtncs_N160cs_c,POST_qtncs_N160cs_c,comments_c) VALUES ("test new add job","-40.07807143,175.73730469","4","4","2013-06-03","13123","","","","","","","0000-00-00","0","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","")
错误消息是
#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法 近 '作为-BuiltImprovementType_1,如-BuiltDiameter_1,如-BuiltDepth_1,如-BuiltSpacing_1,一个' 在第1行
答案 0 :(得分:3)
" AS"是一个保留的MySQL字。
用``围绕你的田地,如:
`as-BuiltDiameter_1`
答案 1 :(得分:2)
-
(连字符)字符是MySQL中的保留字符。要在列名,表格等名称中使用它,必须引用该名称。
请参阅MySQL文档9.2 Schema Object Names。
注意:虽然可以通过引用它们(包括它们在反引号中)来使用这些名称,但我建议不要使用它,因为它可能会导致问题,例如:使用不正确引用名称的工具,或者稍后切换DBMS的工具。坚持使用字母,数字和下划线。