We can find the index of the first occurrence of a given substring in MySQL using the INSTR() function as follows.
SELECT instr(\'Have_a_good_da
While the above codes work successfully for a single character, they failed when I used them to find the last occurrence of a substring. I therefore recommend the code below for this task:
SELECT LENGTH("my father is my father")
- LOCATE('father', REVERSE("my father is my father"))-(LENGTH('father')-1)
This should return 17