-1

私はこのコードを持っていますが、何か問題があります:

SELECT email, realname INTO OUTFILE "c:/mydata.csv"
SUBSTRING_INDEX(SUBSTRING_INDEX(realname, ' ', 1), ' ', -1) as firstname,
SUBSTRING_INDEX(SUBSTRING_INDEX(realname, ' ', 2), ' ', -1) as lastname,
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n"
FROM mytable;

電子メールと実名フィールドのみを選択し、スペースに遭遇したら実名を 2 つのフィールドに分割します!

エラー:

 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTRING_INDEX(SUBSTRING_INDEX(realname, ' ', 1), ' ', -1) as firstname, SUBST' at line 2
4

1 に答える 1

0

最後にあるINTO OUTFILE必要があります。

SELECT email, realname 
SUBSTRING_INDEX(SUBSTRING_INDEX(realname, ' ', 1), ' ', -1) as firstname,
SUBSTRING_INDEX(SUBSTRING_INDEX(realname, ' ', 2), ' ', -1) as lastname,
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n"
FROM mytable
INTO OUTFILE "c:/mydata.csv";

手入力を参照してください。

于 2013-02-28T11:58:06.780 に答える