tags:

views:

17

answers:

2

Hi,

I have the following sql statement to out put a sql table to a csv file.

Some data found in the column 'content' includes new line charactors which is causing issues, is there a way to replace all \n with 's?

SELECT id, title, content 
INTO OUTFILE '/content.csv'
FIELDS TERMINATED BY ',' ESCAPED BY '\\' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM content
+1  A: 
REPLACE( IFNULL(content , ''), '\n' , '<br/>' ) as content
Ian morgan
A: 

Try:

SELECT id, title, REPLACE(content , CHR(13), ' ') as content
INTO OUTFILE '/content.csv'
FIELDS TERMINATED BY ',' ESCAPED BY '\\' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM content

where CHR(13) represents new line.

Sarfraz