从 MySQL 导出带标题的 CSV 文件的排序问题
我想从 MYsql 导出到按两列排序的 csv,我找到了本教程: http://homepage.mac.com/kelleherk/iblog/C711669388/E20060511141025/index.html 但它不适合我。如果我使用不带括号的语句,它会进行排序,但使用我的标题作为数据行。但如果我使用括号,它根本不会执行任何操作。可能是什么问题? 我的查询是:
SELECT 'type' ,'brand' ,'timecenter_hu' ,'karorauzlet_hu' ,'karorauzlet_hu_diff',
'karorauzlet_hu_link',
UNION (SELECT type, brand, timecenter_hu, karorauzlet_hu,
karorauzlet_hu_diff, karorauzlet_hu_link
INTO OUTFILE 'c://result.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' LINES
TERMINATED BY '\n' FROM
result ORDER BY brand);
I want to export from MYsql to csv with ordered by two columns, i found this tutorial: http://homepage.mac.com/kelleherk/iblog/C711669388/E20060511141025/index.html
But its not working for me properly. If I use the statement without parenthesis, it does the ordering, but using my header as a data row. But if I use the parenthesis, it does not do any oredring at all. What can be the problem?
My query is:
SELECT 'type' ,'brand' ,'timecenter_hu' ,'karorauzlet_hu' ,'karorauzlet_hu_diff',
'karorauzlet_hu_link',
UNION (SELECT type, brand, timecenter_hu, karorauzlet_hu,
karorauzlet_hu_diff, karorauzlet_hu_link
INTO OUTFILE 'c://result.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' LINES
TERMINATED BY '\n' FROM
result ORDER BY brand);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要额外的查询才能导出到 CSV:
I think you will need an extra query to do the export to CSV: