1
我在PHP中使用腳本中MySQL的 - LOAD DATA LOCAL INFILE - 問題如果數據庫表名有連字符
$sqlQueryImport = "LOAD DATA LOCAL INFILE '".$fileNewDataImportInDB."' INTO TABLE " .$sqlTableName
. " CHARACTER SET UTF8"
. " FIELDS TERMINATED BY ';'"
. " ENCLOSED BY '\"'"
. " LINES TERMINATED BY '\n'";
我總是錯誤導入CSV到數據庫表中:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'tbl-test' CHARACTER SET UTF8 FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES T' at line 1"
爲了測試它,我直接在phpmyadmin中將csv導入到數據庫表中並且它可以正常工作。
然後我將數據庫表名「tbl-test」更改爲「tbl_test」並且沒有錯誤。
不允許在數據庫表名中使用「 - 」嗎?或者我必須爲它編寫一個特殊的代碼?
謝謝,現在的作品。 – ebody