Change multiple rows in mysql database at the same time

I have a database with prices from many different products. All in this format: £ 25,000.

I want the following: 25000.

I decided that I should use the foreach loop and use str_replace, but I cannot find a way to remove the pound sign and comma.

I also have a few lines where there are no prices, they are in the database as follows: £ 00

Again, I want to remove the pound sign. I think it should be a different cycle?

Could you explain how this should be done?

+4
source share
2 answers

try it

$new_array = str_replace(array("£",","),array("",""),$old_array); 
+4
source

This will remove the comma and £ (if present) in all your rows at once

 update your_table set your_column = replace(replace(your_column, '£', ''), ',', '') 
+4
source

Source: https://habr.com/ru/post/1410975/


All Articles