简体   繁体   中英

Modify many rows in a mysql database at the same time

I have a database with prices from lots of different products. They're all in this format: £25,000.

What I want is the following: 25000.

I figured I must use a foreach loop and use str_replace, but I can't seem to find a way to delete the pound sign and the comma.

I also have a few rows where the prices are missing, they're in the database as following: £00

Again, I want to delete the pound sign. So that must be a different loop I guess?

Could you explain how it must be done?

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

update your_table
set your_column = replace(replace(your_column, '£', ''), ',', '')

试试这个

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM