私はこのコードを持っていますが、何か問題があります:
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