I'd like to remove a substring in a column via update statement. The substring to replace consists of multiple strings from other different columns but in strict order.
The specification says:
replace(string text, from text, to text)
Example:
field1 |field2 |field3 |field4
---------------------------+-------------+------------+---------------
(varchar)bla abla 123 ooops|(varchar)abla|(varchar)123|(varchar) ooops
The substring to replace consists of strings in field2, field3, field4 and blanks between field2 and field3, field3 and field4. In the given example: "abla 123 ooops".
So, after performing the update statement field1 should only contain the string "bla".
Note: I want to perform this on all rows and not to a particular one.
NULL
.