SELECT * FROM `tbProgramDetls`
WHERE dPrgrmdate
BETWEEN "2015-01-01"
AND "2015-01-08"
INTO OUTFILE 'directory' -> C:\myTable.csv
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
显示错误: -
1064 - 您的SQL语法出错;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近' - > C:\ myTable.csv FIELDS终止于','包含在'"' LINES TERMINATE'在第5行
如何执行此查询。
答案 0 :(得分:2)
您的语法应为:
SELECT * FROM `tbProgramDetls`
WHERE dPrgrmdate
BETWEEN "2015-01-01"
AND "2015-01-08"
INTO OUTFILE 'C:\myTable.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
根据手册 http://dev.mysql.com/doc/refman/5.1/en/select-into.html
的示例SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;