I am using MySql and came across a problem.
I have a column name price(Double) and i want to create a new column in the same table of datatype String and wants to copy the price into new column for all rows present in the table
with fixed length pattern.
example i want to do the following
Price(double) newcolumn(String)
12 00012
1 00001
0 00000
please help me to sort out this problem.
Perhaps something like this could work:
The
FORMATfunction converts the double into a string with 0 decimals and here is the api.The
FORMATintroduces commas to separate thousands so we need to useREPLACEto get rid of those and here is the api.The
LPADfunction left pads with the'0'and here is the api