Christopher Tyler

Remove Characters from a String

I needed to remove an email from a string of emails in PostgreSQL. Below is what I came up with:

1
2
3
data> begin;
data> update progarm.emails set emails = replace(emails,' Marvin@mars.com;',''), comment = 'Remove Marvin from the group.' where name = 'looney';
data> commit;

Using replace() , I was able to remove Marvin. If I wanted to update his email, then I would have done 'TheMartian@mars.com' instead of ''.

<< Previous Post

|

Next Post >>

#Postgresql #Replace()