Fix data from SQL database

Asked

Viewed 87 times

0

I want to correct a table field, because I have values like this: 123456789 and I want to change to 1234567.89

  • What type of data in the column?

  • You need your column to be like decimal(X,X) and then apply the update

  • And the value of receipts, I had saved the values so 1,850,00. but it was not adding up correctly. ai corrected in the table the values by removing the point and the comma. now I want to add the point of the cents

  • I put it as decimal but it stayed decimal(30,0) this correct?

  • Ater to remove the point and comma was 1,850.00 now after having removed the points and commas the value was 185000. what I am needing and put the stitch again to separate the penny 1850.00

3 answers

3


To place the decimals, you just multiply the value by 0.01. 123456789 * 0.01 = 1234567.89

update table coldecimal = coldecimal * 0.01

But first, change the column type.

0

Execute the command:

ALTER TABLE tabela MODIFY coluna DECIMAL(10, 2);
  • when applying this command a value that had it was 3000 stayed 3000.00 I would like it to stay 30.00

0

I got it with the following code

update cad_recibo SET valor_recibo = REPLACE(valor_recibo, '00.00', '.00');

only that if it has some value with pennies does not change. then I wanted some way to make the values with pennies too

Browser other questions tagged

You are not signed in. Login or sign up in order to post.