PostgreSQL REPLACE
From w3cyberlearnings
Contents |
Postgresql replace
Replace a substring in a string.
Syntax replace
- string is a string
- search is a substring to search
- replace is a substring to be replaced.
replace(string, search,replace)
Example 1
test2=# SELECT replace('a wonderful girl, she sings wonderfully','wonderful','bad'); replace ----------------------------- a bad girl, she sings badly (1 row)
Example 2
test2=# SELECT user_firstname, test2-# replace(user_firstname,'m','ea') test2-# FROM profile; user_firstname | replace ----------------+--------- Jim | Jiea king | king Jammi | Jaeaeai Bob | Bob