title: Last index of a given substring in MySQL
body: <p>We can find the index of the first occurrence of a given substring in MySQL using the <code>INSTR()</code> function as follows.</p>
  
  <pre><code>SELECT instr('Have_a_good_day', '_') AS index_position
  </code></pre>
  
  <p>It would display <code>5</code>, the first occurrence of the specified substring which is in this case an underscore <code>_</code>.</p>
  
  <p>I need to obtain the last occurrence of a given character (or a substring) something like the Java <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html#lastIndexOf-java.lang.String-" rel="noreferrer"><code>lastIndexOf(String str)</code></a> method of the String class but I can't find any built-in function in MySQL.</p>
  
  <p>Is there any built-in functionality to achieve this in MySQL?</p>