mysql导出csv文件

SELECT * FROM (select 'id','url','大分类','分类','贴吧名称','关注用户数','帖子数量','简介','帖子名称','楼主ID',
'发表时间','采集时间','首页body','body1','body2','state','replys' union select id,url,大分类,分类,贴吧名称,关注用户数,帖子数量,简介,帖子名称,楼主ID,
发表时间,采集时间,
replace (replace (首页body, char(10), ''), char(13), ''),
replace (replace (body1, char(10), ''), char(13), ''),
replace (replace (IFNULL(body2, 'N/A'), char(10), ''), char(13), ''),state,replys from baidu_088_middle) b INTO OUTFILE '/var/lib/mysql-files/baidu88_b4.csv' FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\r\n' ;

 

此包含标题,值中有逗号与\r\n度可以有效屏蔽

posted on 2018-01-19 16:36  石头hah  阅读(168)  评论(0编辑  收藏  举报

导航