Search code examples
mysqlvarchar

Getting last 5 char of string with mysql query


I have to get last 5 numbers using mysql.

My values are like YOT-A78514,LOP-C4521 ...

I have to get only last five char . How can I do this in query?


Solution

  • You can do this with RIGHT(str,len) function. Returns the rightmost len characters from the string str,

    Like below:

    SELECT RIGHT(columnname,5) as yourvalue FROM tablename