kakuki
kakuki

Reputation: 587

replace string in mysql

I would like to replace "|" with "_" in mysql if meets the following query

SELECT COUNT(*) FROM wp_posts WHERE post_content REGEXP 'text\\(584\\|([a-zA-Z0-9_]+)\\|([a-zA-Z0-9_])'

so if finds for example text(584|g345|2344 should look at the end text(584_g345_2344

Is it possible if I use REGEXP to find matches?

Upvotes: 2

Views: 6550

Answers (1)

Ofir Farchy
Ofir Farchy

Reputation: 8037

You can use:

REPLACE(text_string, from_string, to_string)

More info can be found in here.

EDIT:
However, you cannot mix REGEX and REPLACE.
You'll need to have it done with several queries, have you seen this?

Upvotes: 3

Related Questions