0

Is it possible to search and replace with a regex expression in MySQL?

I have a thousand values on a column containing a JSON string, somewhere inside each JSON are several occurrences of a string that I have to change.

I've already made a PHP script that do the job, but it is a little slow.

Is there a nicer way to do that using only MySQL?

Something like:

UPDATE mytable SET value = "disabled" WHERE data REGEXP '{"field": "(.+)"}'
1

1 Answer 1

1

MariaDB has REGEXP_REPLACE(), which might provide the tool you need.

Sign up to request clarification or add additional context in comments.

Comments

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.