Check out example codes for "mysql into outfile with headers". It will help you in understanding the concepts better.

Code Example 1

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';

Learn ReactJs, React Native from akashmittal.com