Thursday, 13 December 2012

How to remove last character of a string(mysql Query fields)?




SELECT Concat( mid( fieldname, 1, length(fieldname) -1 )
 , REPLACE( mid(fieldname, length(fieldname) ) , ',', "" ) )
 as fieldname FROM tablename
 
OR

Select id, REPLACE(fieldname,',','') from tablename 
where fieldname REGEXP '(.*),' limit 5;

update last character from string mysql

UPDATE tablename SET fieldname = Concat( mid(fieldname,
 1, length(fieldname) -1 ) , REPLACE( mid(fieldname, 
length(fieldname) ) , ',', "" ) ) 

No comments:

Post a Comment