2013-08-27 156 views
0

我正在運行一個SQL,我得到的錯誤。SQL查詢的SQL語法錯誤

insert into pfam_uniprot (UniProtKB-AC, UniProtKB-ID, GeneID, RefSeq, GI, PDB, GO, IPI, UniRef100, UniRef90, UniRef50, UniParc, PIR, NCBI-taxon, MIM, UniGene, PubMed, EMBL, EMBL-CDS, Ensemble, Ensemble-TRS, Ensemble-PRO, Additional_PubMed) values ("Q6GZX4", "001R_FRG3G", "2947773", "YP_031579.1", "81941549,47060116,49237298", "", "GO:0006355,GO:0046782,GO:0006351", "", "UniRef100_Q6GZX4", "UniRef90_Q6GZX4", "UniRef50_Q6GZX4", "UPI00003B0FD4", "", "654924", "", "", "15165820", "AY548484", "AAT09660.1", "", "", "", "") 

我得到的錯誤爲:

(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 '-AC, UniProtKB-ID, GeneID, RefSeq, GI, PDB, GO, IPI, UniRef100, UniRef90, UniRef' at line 1")I am not able to understand. Can anyone let me know. 

感謝

回答

1

你不能在變量名連字符。你需要逃避它們。除去還它說後

insert into pfam_uniprot values ("UniProtKB-AC", "UniProtKB-ID", GeneID, RefSeq, GI, PDB, GO, 
           IPI, UniRef100, UniRef90, UniRef50, UniParc, PIR, "NCBI-taxon", 
           MIM, UniGene, PubMed, EMBL, "EMBL-CDS", Ensemble, "Ensemble-TRS", 
           "Ensemble-PRO", Additional_PubMed 
           ) 
    values ('Q6GZX4', '001R_FRG3G', '2947773', 'YP_031579.1', '81941549,47060116,49237298', '', 
      'GO:0006355,GO:0046782,GO:0006351', '', 'UniRef100_Q6GZX4', 'UniRef90_Q6GZX4', 
      'UniRef50_Q6GZX4', 'UPI00003B0FD4', '', '654924', '', '', '15165820', 'AY548484', 
      'AAT09660.1', '', '', '', ''); 
+0

好的,我現在試試吧 – sam

+0

請注意,MySQL(錯誤地)將雙引號字符串視爲字符串文字而不是模式名稱,您可以通過以下方式解決它:通過反引號(')或引號(「或'啓用'sql_mode'中的'ANSI_QUOTES'標誌,或者使用反引號代替雙引號(但這與其他數據庫不兼容)。 – bobince

1

刪除第一個values

insert into pfam_uniprot values (
         ^^^^^^ 
+0

:我會用變量名雙引號和單引號的字符串值(1064,「您的SQL語法錯誤;檢查對應手冊,您MySQL服務器版本,用於在第1行'-AC,UniProtKB-ID,GeneID,RefSeq,GI,PDB,GO,IPI,UniRef100,UniRef90,UniRef'附近使用的正確語法「) – sam

+1

@sam,字段名稱是否正確?它們之間包含'-'。 – falsetru