1

我尝试使用在线找到的 PHP 脚本但没有成功,所以我恢复使用 mySQL 语法 OUTFILE,这是我正在尝试使用的当前代码,尽管它会引发一些错误

SELECT Name, ID INTO OUTFILE 'data.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM data

它抛出一个错误,如下所示

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING 
4

1 回答 1

2

看起来这个错误是由 PHP 引发的。尝试转义双引号

SELECT Name, ID INTO OUTFILE 'data.csv' 
FIELDS TERMINATED BY ',' 
OPTIONALLY ENCLOSED BY '\"' 
ESCAPED BY '\\' 
LINES TERMINATED BY '\n' 
FROM data

如果上述查询有效,请尝试再次转义反斜杠。

SELECT Name, ID INTO OUTFILE 'data.csv' 
FIELDS TERMINATED BY ',' 
OPTIONALLY ENCLOSED BY '\"' 
ESCAPED BY '\\\\' 
LINES TERMINATED BY '\n' 
FROM data
于 2013-02-20T20:51:48.143 回答