Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Location
    India
    Posts
    23

    Question Unanswered: 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.

  2. #2
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    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

  3. #3
    Join Date
    Dec 2004
    Location
    India
    Posts
    23
    Thnx a lott Jayanta...
    The query worked...

Posting Permissions

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