How to remove the first characters in a column

I have a column containing a row. This number, but is saved as a string. A string can begin with 00 or more than two zeros. I need to remove zeros and insert a new value (after deletion) in another column. The problem is that the number of zeros at the beginning is not fixed. It may be 2 or more. Is it possible to complete this task with MySQL? How?

+4
source share
2 answers

Good advice is provided here :

UPDATE your_table SET column2 = TRIM(LEADING '0' FROM column1) 

assuming the original value is stored in column1 and you want to write 0-trimmed to column2

+8
source

you can use CONVERT(col,UNSIGNED INTEGER) to convert it to a number that leading zeros should remove.

may be

 insert into <table> values(select CONVERT(col,UNSIGNED INTEGER),..... from <table2>); 
+1
source

All Articles