【问题标题】:MYSQL Query results exported to .csv [duplicate]MYSQL查询结果导出到.csv [重复]
【发布时间】:2013-05-13 01:10:31
【问题描述】:

如何将我的 sql 查询结果导出到 .csv 文件?目标是自动化这个过程,查询将从前一天提取记录,然后将它们导出到我选择的目录。如果可能的话,我什至希望将日期添加到文件名中,这样它就不会自动覆盖前一天的结果。

这里是查询:

SELECT g.id, g.name, g.date, g.date_mod, g.status, cree_par, modifier_par
FROM glpi_tickets g , (select id, concat(realname , ' ' , firstname)
cree_par from glpi_users ) c, (select id, concat(realname , ' ' ,
firstname) modifier_par from glpi_users) m
where users_id_recipient <> users_id_lastupdater
and users_id_recipient = c.id
and users_id_lastupdater = m.id;

【问题讨论】:

    标签: mysql sql csv cron


    【解决方案1】:

    如何在:

    https://ariejan.net/2008/11/27/export-csv-directly-from-mysql/,

    MySQL export into outfile : CSV escaping chars

    http://www.electrictoolbox.com/mysql-export-data-csv/

    如果要导出到 Excel .xls 或 .xlsx,请安装 PHPtoExcel 或 PHPExcel。

    有一个用于 PEAR 和一个 NON-PEAR 版本。后者效果更好!

    【讨论】:

      猜你喜欢
      • 2018-02-04
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 2014-05-29
      • 2014-02-02
      相关资源
      最近更新 更多