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 + insert a delimiter between fields

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-04, 13:33
szkll9 szkll9 is offline
Registered User
 
Join Date: Mar 2004
Posts: 1
Question SELECT + insert a delimiter between fields

I'm trying to run a select statement from a single db table. I'm going to take my results and put it in to an Excel spreadsheet. The problem is that some of the records have empty fields in the table, so the spreadsheet turns out all screwed up. Is it possible to insert a comma or some other kind of delimiter between each field in each record? Or is there another way to do this?


ie

select last_name, first_name, ssn, dob from employee

returns the following:

Jones Frank 123-45-6789 02/09/1956
Smith Sue 04/19/1980
Simmons 123-45-1234 08/10/1970

I'd like to have it return this:

Jones, Frank, 123-45-6789, 02/09/1956
Smith, Sue, , 04/19/1980
Simmons, , 123-45-1234, 08/10/1970
Reply With Quote
  #2 (permalink)  
Old 03-04-04, 14:40
willi.st willi.st is offline
Registered User
 
Join Date: Feb 2004
Location: Vienna/Austria
Posts: 7
select concat(last_name, ',', first_name, ',', ssn, ',', dob) from employee


... or try '\t' instead of ',' if you want a TAB as delimiter.

see at http://www.mysql.com/doc/en/String_f...s.html#IDX1204
and http://www.mysql.com/doc/en/String_syntax.html

w. :-)
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