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?


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

Answered By – user319198

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published