I have this table.
member_id | phone_number
-----------+--------------
1 | 09151234567
2 | 09904897851
3 | 09196332111
4 | 09957935412
5 | 09251279633
6 | 09357489412
7 | 09155974684
(7 rows)
I format the phone_number column to this format (63)xxxxxxxxx. Using this code
update member set phone_number = regexp_replace(phone_number, '0(.)', '(63)');
member_id | phone_number
-----------+---------------
1 | (63)151234567
2 | (63)904897851
3 | (63)196332111
4 | (63)957935412
5 | (63)251279633
6 | (63)357489412
7 | (63)155974684
(7 rows)
And now I need to update this column again to this format (63)xxx-xxxxxx.
I don't want to replace a character, I need to insert a character in between the string.
I've tried using substring, regexp_replace but failed. I'm doing something wrong. I did find questions somehow related to this but they are all about string replacement.
substring(phone_number from 1 for 7) || '-' || substring(phone_number from 8)?