0

このMySQLを実行して、いくつかのデータをcsvファイルにインポートしようとしています。

SELECT *
FROM purchase WHERE purchase.PO_DATE >= '1-1-2016'
INTO OUTFILE "D:\\Reports\\Jan.csv"
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

しかし、私は出力を受け取っています

Static analysis:

11 errors were found during analysis.

    Unrecognized keyword. (near "FIELDS" at position 99)
    Unrecognized keyword. (near "TERMINATED" at position 106)
    Unrecognized keyword. (near "BY" at position 117)
    Unexpected token. (near "','" at position 120)
    Unrecognized keyword. (near "ENCLOSED" at position 125)
    Unrecognized keyword. (near "BY" at position 134)
    Unexpected token. (near "'"'" at position 137)
    Unrecognized keyword. (near "LINES" at position 142)
    Unrecognized keyword. (near "TERMINATED" at position 148)
    Unrecognized keyword. (near "BY" at position 159)
    Unexpected token. (near "'\n'" at position 162)

SQL query: Documentation

SELECT * FROM purchase WHERE purchase.PO_DATE >= '1-1-2016' INTO OUTFILE "D:\\Reports\\Jan.csv" FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' 

誰でもこの問題を解決する方法を知っていますか?

4

2 に答える 2

4

出力ファイルに関する情報は、句SELECTFROM句の間に指定する必要があります。

SELECT *
INTO OUTFILE "D:\Reports\Jan.csv"
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'    
FROM purchase 
WHERE purchase.PO_DATE >= '1-1-2016'

MySQL 5.7 リファレンス マニュアル | LOAD DATA INFILE 構文

于 2016-11-10T11:05:41.757 に答える
1

from 句が間違った位置にある

SELECT * 
INTO OUTFILE "D:\Reports\Jan.csv"
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM purchase 
WHERE purchase.PO_DATE >= '1-1-2016'
于 2016-11-10T11:04:30.717 に答える