0

I want to write column headers into my csv files, and cannot figure out how, using select .. into syntax.

I've visited this page, as well as looking at some SO posts on the subject. I am wondering if MySQL's select .. into provides a feature to write the column headers or if there's another way to do that, while still writing a .csv file. A plain select at the command line does write the column headers.

Ben
  • 60,438
  • 111
  • 314
  • 488
octopusgrabbus
  • 10,555
  • 15
  • 68
  • 131
  • possible duplicate of [Include headers when using SELECT INTO OUTFILE?](http://stackoverflow.com/questions/5941809/include-headers-when-using-select-into-outfile) – Ryan Mar 15 '13 at 15:48
  • This should be closed. It is a duplicate of http://stackoverflow.com/questions/5941809/include-headers-when-using-select-into-outfile I voted to close. – octopusgrabbus Mar 15 '13 at 16:48

1 Answers1

-1

Ugly, but solves your proble,

select * INTO OUTFILE from (
select 'col1', 'col2', 'col3'
UNION ALL
select col1, col2, col3 from table_name) as t
georgecj11
  • 1,600
  • 15
  • 22