How to use the "replace" function in PostgreSQL to replace a string

I want to replace the row in some data in the pgsql column of a database. I tried

 CASE WHEN (po.siteid IS NOT NULL) THEN replace('po.html_content', 'abcd', 'xxx') ELSE pc.html_content END 

I want to replace the row in the column po.html_content . But the above code does not work. The request receives data in the column po.html_content without replacement. Is my code wrong or any idea ...

+4
source share
1 answer

Do not insert the column name in a single quote , in this case it is no longer a column, but a regular string.

 CASE WHEN (po.siteid IS NOT NULL) THEN replace(po.html_content, 'abcd', 'xxx') ELSE pc.html_content END 
+6
source

Source: https://habr.com/ru/post/1435188/


All Articles