Sum of 3 numeric values stored in a single mysql field

Hi everyone! I know that can’t be correct but I would have to sum 3 numeric values stored in a single mysql field.
In the field called valori_varianti I have 3 decimal numbers 1.00 1.50 1.50. How can I get the sum of these numbers?
I tried to use str_replace to get a result similar to this 1.00+1.50+1.50 but anyway if I recall the sum I don’t get the result of 4.00 but the string 1.00+1.50+1.50.
I also tried using array_sum but it still doesn’t work.
I don’t know if I explained myself well and I apologize if my English is not correct but I use google translate.

You are 100% correct that its not correct to store 3 values in a single field. Bad database design.

explode the value into 3 values in an array, and then array_sum it.

Thanks a lot, I’m the first to reply. I did it! In fact I wanted to understand if it could be done.
Best regards

1 Like