我有下面的查询导出到具有 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