2010-04-26 153 views
0

對不起,我不想問這樣的具體問題的具體問題,但這是駕駛我精神!快速mysql查詢問題

有一定有一些東西很明顯我失蹤:

表:

|ven_name|varchar(150)|No| 
|ven_sd|varchar(90)|Yes|NULL 
|ven_details|varchar(3000)|Yes|NULL 
|ven_tel|varchar(30)|Yes|NULL 
|ven_email|varchar(50)|Yes|NULL 
|ven_address|varchar(300)|Yes|NULL 
|lat|decimal(9,6)|Yes|NULL 
|long|decimal(9,6)|Yes|NULL 
|pub|tinyint(4)|Yes|NULL 
|bar|tinyint(4)|Yes|NULL 
|club|tinyint(4)|Yes|NULL 
|img_added|tinyint(4)|Yes|NULL 

查詢:

INSERT INTO ven 
      (img_added, 
      ven_name, 
      ven_sd, 
      ven_tel, 
      ven_email, 
      ven_address, 
      lat, 
      long, 
      pub, 
      ven_details) 
VALUES  (1, 
      'aaa', 
      'aaa', 
      'aaa', 
      'aaa', 
      'aaa', 
      100, 
      156, 
      1, 
      'aaa') 

錯誤:

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 'long, pub, ven_details) VALUES(1, 'aaa', 'aaa', '0117 9246449', 'aaa', 'aaa', 10' at line 1 
+0

奇怪,它的製作單詞'long'藍色? – Haroldo 2010-04-26 12:09:31

+4

這就是告訴你問題是什麼! :-) – RichieHindle 2010-04-26 12:15:37

回答

0

這是long,它在MySQL中的保留字。有趣的是,語法高亮似乎抓住它:)

重命名列或使用反引號:

`lat`, 
`long`, 
`pub`, 

參考:mySQL reserved words

0

LONG is a reserved mysql word.

更改它LNG或者你可以做到這一點:

INSERT INTO ven 
      (img_added, 
      ven_name, 
      ven_sd, 
      ven_tel, 
      ven_email, 
      ven_address, 
      lat, 
      `long`, 
      pub, 
      ven_details) 
VALUES  (1, 
      'aaa', 
      'aaa', 
      'aaa', 
      'aaa', 
      'aaa', 
      100, 
      156, 
      1, 
      'aaa')