Ram
Ram

Reputation: 825

update statement with replace in postgresql

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 

Upvotes: 0

Views: 801

Answers (1)

Marian
Marian

Reputation: 4079

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.

Upvotes: 3

Related Questions