Is it possible to REPLACE a string + next character in MySQL? Something like LIKE underscore.
For example, if text column is this:
12 13 14 14_B 15 14_A, REPLACE all 14_* with an empty character, and replaced text should be:
12 13 14 15
You’ll be looking to do this using a regular expression UDF in MySQL. Key ingredients are
If you will ONLY ever see 2 to 4 of these that you need replaced, a poor man’s working approach (SQL Fiddle):
I’ve only catered for 3 replacements but you can easily expand the pattern. Include only the columns from the base table needed in the outermost query.