2

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'); 
1
  • 1
    You want to find a string and use replace? Could you please give more info. Commented Apr 14, 2012 at 13:06

2 Answers 2

1

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]+'
Sign up to request clarification or add additional context in comments.

Comments

1

Maybe you need:

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

3 Comments

To be more specific, here's one of the urls. Im trying to replace the "catid=51" with catid="7". Each url is different: index.php?option=com_content&view=article&id=149:multiple-objectives-when-deciding-to-sell-a-medical-practice&catid=51:articles&Itemid=114
They all exist within the same table and field name, if that helps
Now you are talking about urls. Please show us some real data from real tables instead of your meta-babble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.