How would I go about having my sql query results exported to a .csv file? The goal is to automate this process, the query would pull records from the previous day and then export them to a directory of my choosing. If possible, I'd even like to have the date added to the filename so it doesn't automatically overwrite the previous day's results.
here is the query :
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;
Answer
HOWTOs at:
https://ariejan.net/2008/11/27/export-csv-directly-from-mysql/,
MySQL export into outfile : CSV escaping chars
and
http://www.electrictoolbox.com/mysql-export-data-csv/
If you want to export to Excel .xls or .xlsx install PHPtoExcel or PHPExcel.
There is one for PEAR and a NON-PEAR version. The later works better!
No comments:
Post a Comment