在 PostgreSQL 中使用替换更新语句

upate statement using replace in PostgreSQL

我table有以下记录

Sno  A
-    --
1   spoo74399p 
2   spoo75399p 

我想通过将 oo(字母表 'o')替换为零来更新上述记录

Required OUTPUT
----------------
Sno     A

1   sp0074399p 
2   sp0075399p 

I want to update the above records by replacing oo (alphabet 'o') by zero

这是您要找的吗?

update mytable set a = replace(a, 'oo', '00')

我可能会在这里使用 REGEXP_REPLACE 来尽可能具体:

UPDATE yourTable
SET A = REGEXP_REPLACE(A, '^spoo', 'sp00');

这只会针对 oo 发生在 sp 之后的开头附近的 oo