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 > DB2 > Concatination of strings having either value NULL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-07-05, 06:26
madhuri_awal madhuri_awal is offline
Registered User
 
Join Date: Dec 2004
Location: India
Posts: 23
Question Concatination of strings having either value NULL

Hii all....
In IBM DB2 for concatenation query as:

'SELECT FIRST_NAME || MID_NAME || LAST_NAME AS NAME FROM INFO'

If either of the 3 values is NULL, I get the concatenated string as NULL....Is there any way that I get the correct result string (Not NULL) even if any value is NULL??

Thanks in advance,
Madhuri.
Reply With Quote
  #2 (permalink)  
Old 03-07-05, 07:21
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
You can try the following query. I have just put the values 9,5,9 etc. In your case you put some logical values against them depending upon the datatype length.

'SELECT CHAR(COALESCE(FIRST_NAME,''),9) || CHAR(COALESCE(MID_NAME ,''),5) || CHAR(COALESCE(LAST_NAME,''),9) AS NAME FROM INFO'


Jayanta
Reply With Quote
  #3 (permalink)  
Old 03-07-05, 08:22
madhuri_awal madhuri_awal is offline
Registered User
 
Join Date: Dec 2004
Location: India
Posts: 23
Thnx a lott Jayanta...
The query worked...
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