title: MySQL search within the last 5 characters in a column?
body: <p>My user table has a column "name" which contains information like this:</p>
  
  <pre><code>Joe Lee
  Angela White
  </code></pre>
  
  <p>I want to search for either first name or last name efficiently.  First name is easy, I can do </p>
  
  <pre><code>SELECT * FROM user WHERE name LIKE "ABC%"
  </code></pre>
  
  <p>But for last name, if I do</p>
  
  <pre><code>SELECT * FROM user WHERE name LIKE "%ABC"
  </code></pre>
  
  <p>That would be extremely slow.</p>
  
  <p>So I am thinking about counting the characters of the input, for example, "ABC" has 3 characters, and if I can search only the last three characters in name column, that would be great. So I want something like</p>
  
  <pre><code>SELECT * FROM user WHERE substring(name, end-3, end) LIKE "ABC%"
  </code></pre>
  
  <p>Is there anything in MySQL that can do this?</p>
  
  <p>Thanks so much!</p>
  
  <p>PS. I cannot do fulltext because our search engine doesn't support that.</p>