Cómo truncar el carácter inicial de una cadena en mysql para una condición específica

I want to truncate the first letter of a string which have size more than 11 character. I know I can use substring function like

SELECT SUBSTRING(name, 1, 10) from table1;

which will truncate and return me the first 10 letter. what should I do if I want to remove the character from the beginning if the string is greater than 10 character.

abcdefghijklmn ==>  efghijklmn

preguntado el 27 de noviembre de 13 a las 01:11

2 Respuestas

¿Qué tal RIGHT():

SELECT RIGHT(name, 10)
FROM table1;

Demostración: Violín SQL

RIGHT() returns a specified number of characters from the right side of a string. If you want to apply any function only in certain situations, a CASE statement can be used.

respondido 27 nov., 13:01

create table table1(name char(25));

insert into table1 values('abcdefghijklmn'); select right(name,10) from table1;

RIGHT() is the function you need to use.

respondido 27 nov., 13:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.