Sql select replace

Hi All,

I had a query related to sql select replace command.
i have a table named clusters and it looks like this

Code:
name characteristics
sample 1.1 parent
sample 1.2 clone
sample 1.3 clone
sample 1.4 parent
sample 1.5 parent
sample 1.6 clone
sample 2.1 parent

I want all my entries named "sample" to" data" I need like bulk entries changed.

The table should look like this

clusters

Code:
name characteristics
data 1.1 parent
data 1.2 clone
data 1.3 clone
data 1.4 parent
data 1.5 parent
data 1.6 clone
data 2.1 parent

Is it possible using a select replace and update statement?
Please do help

I did use this

SELECT REPLACE ('clusters','sample','data');

but it didnt work

I also thought it might because of spacing between sample and number
I used this

SELECT REPLACE ('cluster','sample*','data*');
but that didnt work too.

Please advise

You are doing it wrong!

To update string: sample to data , use below SQL:

update clusters set name = replace(name, 'sample', 'data');

Before committing select & verify the output:

select name, characteristics from clusters;

Note: Also the wildcards used in SQL are % and _ not * and ?

1 Like

thanks a ton!!:slight_smile: