php - Mysql / export query result in csv file -


i have mysql script select needed data via left join , save result in csv file. problem column names missed in result file. doing wrong ?

select  a.*, b.pr_name outfile 'johnoggyresult3.csv'     fields terminated ','     enclosed '"'     lines terminated '\n'     `fileb` b left join     `filea` on b.pr_hand_size = a.user_hand_size order      a.user_id 

just add columns names select. should work:

select *   outfile 'johnoggyresult3.csv' fields terminated ',' enclosed '"' lines terminated '\n'  ( select 'column1', 'column2' union (select  a.column1, b.pr_name     `fileb` b left join     `filea` on b.pr_hand_size = a.user_hand_size order      a.user_id) q ) 

please note dumping csv done @ end, after result fetched , sorted , after headers attached dataset. need sort data first before adding row headers or otherwise headers sorted , land somewhere in middle of dataset instead of top intended.


Comments

Popular posts from this blog

javascript - Replicate keyboard event with html button -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Web audio api 5.1 surround example not working in firefox -