Oracle UPDATE statement using REPLACE function

I am trying to remember how to generate the correct REPLACE statement in Oracle SQL.

In essence, I need to run REPLACE over several thousand records, in which column1 and column2 can contain the value '14' . If so, I need to replace it with just a space character.

I know that the syntax is similar to the following, but I cannot understand that it is right:

 UPDATE TABLE SET ('column1', 'column2') = REPLACE(?????????????) WHERE 'column1' IN ('14') AND 'column2' NOT LIKE ('4%') 

Any help would be appreciated.

+4
source share
2 answers

The query should look something like this:

 UPDATE table1 SET column1 = REPLACE(column1, '14', ' '), column2 = REPLACE(column2, '14', ' ') WHERE column1 LIKE '%14%' OR column2 LIKE '%14%' 
+9
source
 UPDATE TABLENAME SET COLUMN1 = ' ', SET COLUMN2 = ' ' WHERE COLUMN1='14' OR COLUMN2='14'; 

The proposed column [1,2] has a character type.

+1
source

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


All Articles