How to delete leading characters of a string in MySQL

Here's one way to do it!
In this case, I wanted to remove all the characters to the left of and including a hyphen (-):

UPDATE table
SET column =
substring_index(column,'-',-1);

to get the reverse (trailing characters), change the -1 to 1

UPDATE table
SET column =
substring_index(column,'-',1);

Leave a Reply

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

Shares