how to export data with column headers in mysql server code example
Example 1: mysql into outfile with headers
SELECT * FROM (
SELECT 'username','email'
UNION ALL
(
SELECT `username`,`email`,`steam_id` FROM `users` WHERE `userna` LIKE '%@temp%'
)
) resulting_set
INTO OUTFILE '/results/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
Example 2: export mysql table to file
mysqldump db_name tbl_name;