This is a tricky one, but the best way to go about it is to first reverse the string then find the first occurence of the string. Then subtract the length of the string from the location of the string you are looking for, then use SUBSTRING to get the values you require.

The example below will update a column in a table with the value after the last occurence of a ‘=’ sign in a field.

UPDATE TABLE SET col1 = SUBSTRING( col2, (LENGTH( col2 ) - LOCATE( '=', REVERSE( col2 ) ) ) +2)

How do I get the last occurence of a character from a string using MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *

seventy one + = 75