mysql > select m.asset_id, m.asset_name, m.director, m.actor, m.country_of_origin, m.years, concat(‘http://192.167.1.120:15414/‘,p.poster_url),m.category from ao_movie_tab m, ao_poster_tab p where m.asset_id = p.asset_id group by m.asset_id order by m.asset_id INTO outfile ‘test.txt‘ FIELDS terminated by ‘\,‘;
字段以逗号分隔,导出的test.txt文件在数据库路径下
以下参考http://www.cnblogs.com/xh831213/archive/2012/04/10/2439886.html
2.导出数据格式
字段之间的分隔字符,转义字符,包括字符,及记录行分隔字符。列在下面:
FIELDS
TERMINATED BY ‘\t‘ 字符分隔符
[OPTIONALLY] ENCLOSED BY ‘‘
ESCAPED BY ‘\\‘
LINES
TERMINATED BY ‘\n‘
TERMINATED 表示字段分隔
[OPTIONALLY] ENCLOSED 表示字段用什么字符包括起来,
如果使用了OPTIONALLY则只有CHAR和VERCHAR被包括 ESCAPED 表示当需要转义时用什么作为转义字符
LINES TERMINATED 表示每行记录之间用什么分隔
mysql导出到xls文件sql试例
mysql> mysql bulldog -h1.1.1.1 -uroot -p1234 -e "select user_id,b.terminal_sn,charge_time,type,money,vmoney from ao_member_charge_tab a, ao_member_tab b where a.user_id=b.id and a.status=1 and money > 1.0;" > /BullDog/chongzhi_user_new.xls
本文出自 “坚持。。。” 博客,请务必保留此出处http://qchanblog.blog.51cto.com/9686614/1902121
mysql导出文件到txt并指定字段分隔符;mysql导出到xls文件sql试例
原文地址:http://qchanblog.blog.51cto.com/9686614/1902121