Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I was wondering how to go replacing a series of strings in batch. For example if I wanted to remove full stops from a field and also change double spaces between characters into single spaces. I know using Python one can simply use something like: .replace('.','').replace(' ', ' ').replace(etc.). Using postgresql it would look more like

UPDATE table
SET field = replace(field, 'replace text','replacement text')

I'm not sure how to get this to work for multiple replacement options. Thanks for any help you can provide.

share|improve this question
up vote 1 down vote accepted

You can use REPLACE() function multiple times like

UPDATE table
SET field = replace(replace(field, '.',''),'  ',' ')
share|improve this answer
    
Thanks @Rahul, that was what I was looking for, I'm very new to postgres and tried a series of replace functions outside of the parens and it failed. – standard Aug 4 '14 at 21:18
    
If the answer helped then consider accepting it. – Rahul Aug 4 '14 at 21:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.