Hi Ariel,

Maybe this example helps you to create CSV output from MySQL.
The first SELECT generates the headerline; the second the data.
( SELECT 'FieldA','FieldB','FieldC', ... )
UNION
( SELECT `FieldA`, `FieldB`, `FieldC`, ...
 INTO OUTFILE 'D:/MySQL Datafiles/myFile.csv'
 FIELDS TERMINATED BY ','
 LINES TERMINATED BY '\r\n'
 FROM ... ...
 GROUP BY `FieldA`, `FieldB`, `FieldC`, ...
);

Don't forget the braces ( and ).
HTH, Cor



----- Original Message ----- From: "Ariel Sánchez Mora" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Monday, March 06, 2006 8:12 PM
Subject: 'Into outfile' doesn't include the column names. How can it be done?


When using select into outfile, I can only get the table data, but I can't find how to include the column names. I haven't been able to include the column names into the actual return of the query, and they don't get stored in the .csv

Anyone know how to include the column names, table name, other info, as an actual answer from MySQL? I realize that when I use the command line I can see the column names, but this is not the case when using, for example, Delphi, and my real problem, when the outfile is made.

I use SQLyog for exporting to csv and they do include the columns, my bet is its some SQL option. The manual doesn't specify, at least in the select syntax part.

Ariel




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to