【问题标题】:Mysql query deleimiter in a file文件中的Mysql查询分隔符
【发布时间】:2011-11-14 09:05:11
【问题描述】:

在下面的查询中,如果 desc 中包含“\”,并且当 openoffice 打开此文件时,\ 并出现在不同的列中。这也发生在 city 列中,如何解决这个问题..

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 ",";

【问题讨论】:

    标签: mysql into-outfile


    【解决方案1】:

    添加ESCAPED BY 子句以转义转储中的特殊字符。

    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 "\";
    

    【讨论】:

      猜你喜欢
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-17
      相关资源
      最近更新 更多