Reputation: 43
I have an MySQL table like this:
-------------------------------------------
|ID | Name | Value |
| 1 | Jack | 1.0382948092380932980293 |
| 2 | John | 12.3489245802843509384001 |
| 3 | Bill | 6.0293892838236487263872 |
-------------------------------------------
I want to update Values to three-digit decimal number after the comma like the scheme below.
------------------------
|ID | Name | Value |
| 1 | Jack | 1.038 |
| 2 | John | 12.348 |
| 3 | Bill | 6.029 |
------------------------
How can I do this using MySQL sentence? Thank you.
Upvotes: 4
Views: 7088
Reputation: 1201
You want to round up the value use jherran answer,
But I think you want to round down the value, so you should use: truncate
function
update tablename set fieldname = truncate(fieldname ,3)
refer to : https://stackoverflow.com/a/69548823
Upvotes: 0
Reputation: 3367
You need to use round
:
update tablename set fieldname = round(fieldname,3)
Upvotes: 5