Jump to content

Recommended Posts

Hi,

 

I am able to concat 3 fields using following command but if any field is empty or null then I am not getting concate string.

       

        I am getting empty string.

 

SELECT CONCAT(account.phone_country_code,'-',account.phone_city_code,'-',account.phone) AS phone FROM account

 

I try for CONCAT_WS from MYSQL documentation but not able to achibe result.

 

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws

 

Any solution for this problem?

 

-Thanks

Link to comment
https://forums.phpfreaks.com/topic/256605-concat_ws-and-concat-help/
Share on other sites

Hi

 

What is the problem you are having with it?

 

SELECT CONCAT_WS('-',account.phone_country_code,account.phone_city_code,account.phone) AS phone 
FROM account

 

Or is it that blank columns are skipped on a row? If so use IFNULL on each column.

 

All the best

 

Keith

Thanks.

 

 

I am getting result but if column in empty then I am getting separator in string like following.

 

----123-123456

 

---123-123456

 

--123-123456

 

It is possible not to include column and separator if column in empty?

 

- Thanks.

 

-123-123456

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.