A field of a table in Msql stores a person's address, and one day a certain place in this address
If his name changes, his address will also change:
for example:
It turned out to be:
table name: user_item, field: addr
- number addr
- 01 No. 05, XXXXXX Street, Chengdu City, Sichuan Province
- 02 No. 07, XXXXXX Street, Chengdu City, Sichuan Province
- 03 No. 09, XXXXXX Street, Chengdu City, Sichuan Province
- 04 No. 04, XXXXXX Street, Chengdu City, Sichuan Province
Now the city of Chengdu has become a "Tianfu" city...
Therefore, all the values in the addr field should be changed from Chengdu to Tianfu
Solution:
sql statement:
- update table name set field name=REPLACE (field name, 'original value', 'value to be modified')
Of course, you can also add conditions:
- update user_item set addr=REPLACE (addr,'成都','天府') where time<'2013-11--5'
- <strong><span style="color:#FF6666;">UPDATE `dqca02` SET `qt` = REPLACE (qt,'?aaaa','aaaa')//The table is dqca02, the field is qt, and the content is "?aaaa", all changed to "aaaa"</span></strong>
The final effect:
- number addr
- 01 No. 05, XXXXXX Street, Tianfu City, Sichuan Province
- 02 No. 07, XXXXXX Street, Tianfu City, Sichuan Province
- 03 No. 09, XXXXXX Street, Tianfu City, Sichuan Province
- 04 No. 04, XXXXXX Street, Tianfu City, Sichuan Province