Column names from MySQL to CSV file
csv, excel, mysql, sql
Solution
I found a solution to my problem. would slap myself.
SELECT *
INTO OUTFILE '/xampp/tmp/Sample.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
FROM
(
SELECT 'Name' AS `E_Name`, 'Email' AS `Email`
UNION ALL
SELECT `E_Name`, `Email`
FROM `email`
) `sub_query`
before the new line i wasnt doing a return. once i added this the csv can be imported into outlook no problem. Thanks for the help though all. ill leave this open incase anyone else has the same problem.
*face palm*
Problem
i've a table in a database i would like to use as a contacts table to import into outlook. what i would like the import to do is this: name | email andy | ds@ds.com <--name and email entered at the moment i have this code: ``` (SELECT 'Name', 'Email') union all (select E_Name, Email INTO OUTFILE '/xampp/tmp/Sample.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM email WHERE 1) ``` this creates an excel file like this: A | B <-- excel column names Name | Email andy | ds@ds.com i know if i pull the information using odbc connection it pulls the information the way i require, however i want it so the csv file is created with this information already in it, thus removing the need to do the odbc method.