批量插入命令中的MySQL错误,

时间:2014-05-19 21:26:47

标签: mysql sql

我在下面的查询中遇到错误:

      INSERT INTO EDGAR.8k_form_doc_info  (ticker, SECAccessionNo, seq, description, document, docUrl, type, size) VALUES ('ATVI','0000950138-03-000610','1','\ACTIVIS\2003 FILINGS\NOV 8-K\','nov8-k.txt','/Archives/edgar/data/718877/000095013803000610/nov8-k.txt','8-K','3102')

错误日志:

      INSERT INTO EDGAR.8k_form_doc_info  (ticker, SECAccessionNo, seq, description, document, docUrl, type, size) VALUES ('ATVI','0000950138-03-000610','1','\ACTIVIS\2003 FILINGS\NOV 8-K\','nov8-k.txt','/Archives/edgar/data/718877/000095013803000610/nov8-k.txt','8-K','3102')    Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'nov8-k.txt','/Archives/edgar/data/718877/000095013803000610/nov8-k.txt','8-K','3' at line 2    0.031 sec

查询有什么问题??

1 个答案:

答案 0 :(得分:0)

错误在这里,'\ACTIVIS\2003 FILINGS\NOV 8-K\','nov8-k.txt'。您实际上是通过说'来转义\'。你也需要逃避\。否则,Db引擎认为字符串nov8-k.txt没有起始单引号。

更改您的查询,如

INSERT INTO EDGAR.8k_form_doc_info  (ticker, SECAccessionNo, seq, 
description, document, docUrl, type, size) 
VALUES ('ATVI','0000950138-03-000610','1','\\ACTIVIS\\2003 FILINGS\\NOV 8-K\\',
'nov8-k.txt','/Archives/edgar/data/718877/000095013803000610/nov8-k.txt',
'8-K','3102')