0

I have table having below records

Sno  A
-    --
1   spoo74399p 
2   spoo75399p 

I want to update the above records by replacing oo (alphabet 'o') by empty after sp afte Required OUTPUT ---------------- Sno A

1   sp74399p 
2   sp75399p 
1
  • 1
    Unrelated to your problem, but: Postgres 9.2 is no longer supported you should plan an upgrade as soon as possible. Commented Feb 14, 2020 at 7:55

1 Answer 1

3
UPDATE my_table
SET A = REPLACE(A, 'spoo', 'sp');

This would update all the records.

To clarify a bit, this would find any instances of "spoo" and replace them with "sp". The end result is that any "oo" right after "sp" would be deleted.

Sign up to request clarification or add additional context in comments.

4 Comments

i think sp should not come.'oo' replaced by empty.so Replace(A,'oo','').is it correct?
@Ram You can also replace 'oo' with ''. It's just a rule of thumb to replace the longer sequence. This way if you find 'oo' in a different part of the string, it will not be replaced.
if i put sp in replace command it replace the 'oo' by 'sp'.but i want to replace 'oo' with empty.so pls give the update command for this.
If you want to replace oo with empty after sp, use the command in my answer. If you want to replace any oo with empty, use REPLACE(A, 'oo', '').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.