Scott Greenwald
Scott Greenwald

Reputation: 191

SQL Find & Replace part of a string

I'm trying to find certain text "catid=18" in a string, where each string is different except for this. I've used this query below before, except it only seems to work if you know the entire string.

update TABLE_NAME
set FIELD_NAME = replace(FIELD_NAME, 'findthis', 'replacewiththis'); 

Upvotes: 2

Views: 1380

Answers (2)

wildplasser
wildplasser

Reputation: 44250

Maybe you need:

update TABLE_NAME
set FIELD_NAME = 'goodvalue'
WHERE FIELD_NAME = 'badvalue'; 

Upvotes: 1

juergen d
juergen d

Reputation: 204904

Not sure if that is what you want. But it will return 1 if catid=any_num is found and 0 if not:

select 'some_text catid=18 some_text' REGEXP 'catid=[0-9]+'

Upvotes: 1

Related Questions