lastindexof
Last index of a given substring in MySQL
@Marc B was close. In MySQL, following statement returns 12: SELECT CHAR_LENGTH(“Have_a_good_day”) – LOCATE(‘_’, REVERSE(“Have_a_good_day”))+1; Anticipating a possible use of the value, the following statement extracts the left part of the string before the last underscore(i.e., _): SELECT LEFT(“first_middle_last”, CHAR_LENGTH(“first_middle_last”) – LOCATE(‘_’, REVERSE(“first_middle_last”))); The result is “first_middle”. If you want to include the delimiter, use: … Read more