Rajeev
Rajeev

Reputation: 46919

Mysql query deleimiter in a file

In the following query if desc has "\" in it and this file when opened by openoffice the \ and appears in a different coulmn.This also happens with city column,How to recitfy this..

select first_name, last_name, emp_id,desc,city from emp_table where event_id = 4 order by city asc   into OUTFILE "/tmp/Sep10-1.csv"   FIELDS TERMINATED BY ",";

Upvotes: 0

Views: 57

Answers (1)

Mchl
Mchl

Reputation: 62387

Add ESCAPED BY clause to escape special characters in dump.

select 
  first_name, last_name, emp_id,desc,city 
from 
  emp_table 
where 
  event_id = 4 
order by 
  city asc   
into OUTFILE 
  "/tmp/Sep10-1.csv"   
FIELDS 
  TERMINATED BY "," 
  ESCAPED BY "\";

Upvotes: 2

Related Questions