If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Select into Outfile with column names?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-06-04, 16:59
japhy1 japhy1 is offline
Registered User
 
Join Date: Nov 2004
Posts: 16
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,
Reply With Quote
  #2 (permalink)  
Old 12-06-04, 19:50
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
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 19:57.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On