2012-02-06 61 views
1

我有進口時執行使用phpMyAdmin以下語句文件看起來像這樣如何在使用phpmyadmin導入時忽略雙引號?

"1106837", "Jabbar", "33.29106", "73.48639", "PK", "Asia/Karachi" 
"1106838", "Dhangdev Saiyidān", "33.26424", "73.41412", "PK", "Asia/Karachi" 
"1106839", "Dheriān", "33.255", "73.42722", "PK", "Asia/Karachi" 
. 
. 
. 

的文件。

LOAD DATA INFILE 'C:\\wamp\\tmp\\phpC108.tmp' INTO TABLE `allcountries` FIELDS 
TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'(
`geonameid` , `place_name` , `lat` , `lng` , `country_code` , `city` 

的問題是雙引號()也被插入到表列。我不需要雙引號從文本文件

回答

0

這是因爲你的字段沒有被,終止,它們被(終止字符串中的額外空間)終止。請嘗試以下操作:

LOAD DATA INFILE 'C:\\wamp\\tmp\\phpC108.tmp' INTO TABLE `allcountries` FIELDS 
TERMINATED BY ', ' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'(
`geonameid` , `place_name` , `lat` , `lng` , `country_code` , `city`) 
+0

謝謝。有用。 – shaikh 2012-02-06 10:27:20

0

刪除空格,MySQL客戶端無法解析它們。

"1106837", "Jabbar", "33.29106", "73.48639", "PK", "Asia/Karachi" 

=>

"1106837","Jabbar","33.29106","73.48639","PK","Asia/Karachi"