Jerfeson Guerreiro
Jerfeson Guerreiro

Reputation: 745

Removing the last character of a field in mysql

I have a procedure that receives 2 parameters I would like to take the last character of one of these parameters does anyone know how to do, using mysql?

CREATE  PROCEDURE `sp_status`(IN status_p CHAR(1), IN codigo_p VARCHAR(255))
BEGIN
UPDATE cartaodigital SET statusPedido = status_p WHERE id_cartaodigital = codigo_p;
END

Upvotes: 1

Views: 3053

Answers (1)

Hunter McMillen
Hunter McMillen

Reputation: 61550

The function you are looking for is SUBSTRING:

select substring(COLUMNNAME from length(COLUMNNAME))
from TABLENAME; 

or

select substring(COLUMNNAME, length(COLUMNNAME))
from TABLENAME; 

or

select substring(COLUMNNAME from -1)
from TABLENAME;

or

select substring(COLUMNNAME, -1)
from TABLENAME;

Upvotes: 2

Related Questions