Mysql 查询文件中的定界符

发布于 2024-12-03 22:10:11 字数 275 浏览 2 评论 0原文

在下面的查询中,如果 desc 中包含“\”,并且该文件在由 openoffice 打开时,\ 会出现在不同的位置中。城市列也会发生这种情况,如何重新执行此操作。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲在坟头点根烟 2024-12-10 22:10:11

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

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 "\";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文