Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    16

    Unanswered: Select into Outfile with column names?

    Hi all,
    does anyone know a good way of selecting data into an output text file
    with the column names at the top?

    i.e. i'd like the text file to look like

    name1,name2,name3
    0,1,2
    3,4,5
    6,7,8

    thanks,

  2. #2
    Join Date
    Mar 2004
    Posts
    480
    You can't do it using a select to an outfile. From this thread:
    http://lists.mysql.com/mysql/163185
    I understand you may get what you want using batch mode.

    Now I ran it directly from my command prompt and saved the file in the current directory (on WinXP, sure the same works for Linux)

    Code:
    echo SELECT * from animal | mysql -udavemysql -p***** testdb > mysqloutfile.txt
    I found I had to name the database i was using or of course got the no db selected error message.
    Last edited by guelphdad; 12-06-04 at 20:57.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •