HTML 値を持つ列本体を含む CSV にエクスポートするクエリを以下に示します。
問題は、コンマをスペースに置き換えても、正しく表示されず (正しく表示されないなど)、行が改行で終了しないことです。
SELECT j.id,j.title,j.featured,REPLCAE(j.body,',',' '),j.created,j.created_by,j.start_date,j.end_date,j.apply_link,o.name,o.website,o.logo,o.created,p.code,p.suburb,s.name INTO OUTFILE '/tmp/careersandjobs.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM job j
LEFT JOIN portfolio_job pj
ON pj.job_id = j.id
LEFT JOIN organisation o
ON o.id = j.organisation_id
LEFT JOIN postcode p
ON p.id = j.postcode_id
LEFT JOIN state s
ON s.id = p.state_id
WHERE published = 1
AND end_date > CURDATE()
AND pj.port_id = 8
これには理由がありますか?
@マイケル
私はあなたが提案したことを試しましたが、今ではこのエラーが発生します:
Failed to execute SQL : SQL SELECT j.id,j.title,j.featured,REPLACE(j.body,',',' ') as body,j.created,j.created_by,j.start_date,j.end_date,j.apply_link,o.name,o.website,o.logo,o.created,p.code,p.suburb,s.name INTO OUTFILE '/tmp/careersandjobs.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY "\n" FROM job j LEFT JOIN portfolio_job pj ON pj.job_id = j.id LEFT JOIN organisation o ON o.id = j.organisation_id LEFT JOIN postcode p ON p.id = j.postcode_id LEFT JOIN state s ON s.id = p.state_id WHERE published = 1 AND end_date > CURDATE() AND pj.port_id = 8 failed : Field separator argument is not what is expected; check the manual