Link to home
Start Free TrialLog in
Avatar of nisupport
nisupport

asked on

Replace line breaks with a space with using Select.. Into Outfile

I am running a query to download a csv. Some of the fields might contain line breaks, which makes the program reading the file think that the record has ended, messing up the column count. Can I replace the breaks with a space or make it ignore the breaks?
SELECT 
					p.prodid,
					r.id,
					r.rganum,
					p.partnum,
					p.description,
					p.mfgmonth,
					p.mfgyear,
					p.produse,
					p.lot,
					p.amount,
					p.unitMeasure
			INTO OUTFILE '$file2' 
			FIELDS TERMINATED BY ';' 
			LINES TERMINATED BY '\n' 
			FROM 
				ns_rgaproduct p,
				ns_rga r
			WHERE 
				r.status = 'approved' 
				and r.decdate >= '$exportdate'
				and r.id = p.rgaid

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nisupport
nisupport

ASKER

I am still getting the same results. Is there another character for a break to replace? I have tried <br>.
Other than '\n', you can try:
'\r\n'

NOTE:You need to use the replace on every field that may potentially have the newline.
Figured it out needed to put '\r\n' for the line break.
glad to help