In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how mysql implements part of the replacement field. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
[mysql]replace usage
1.replace into
replace into table (id,name) values('1','aa'),('2','bb')
This statement inserts two records into the table. If the primary key id is 1 or 2 and does not exist, it is equivalent to
insert into table (id,name) values('1','aa'),('2','bb')
Data is not inserted if identical values exist
2.replace(object,search,replace)
Replace all search entries in object with replace
select replace('www.163.com','w','Ww')--->WwWwWw.163.com
Example: Replace aa with bb in the name field of table
update table set name=replace(name,'aa','bb')
UPDATE updates part of a field
Now I have a record with a field called "abcdefg" and I just want to change the c in that field to C. How do you write update statements?
update table name set field 1 = replace(field 1,'c',' C')
Knowledge Point Extension:
mysql replace function replace() implements mysql to replace a string in a specified field
How to replace strings with mysql:
The replace function in mysql directly replaces a specific string in a field in mysql database, no longer needs to write its own function to replace it, which is very convenient to use. mysql replace()
UPDATE `table_name` SET `field_name` = replace (`field_name`,'from_str','to_str') WHERE `field_name` LIKE '%from_str%'
Description:
table_name --The name of the table
field_name --field name
from_str --String to replace
to_str --The string to replace
For example:
mysql> SELECT REPLACE('www.lvtao.net', 'www', 'http://www');
-> 'https://www.lvtao.net'
This function is multibyte safe, meaning you don't have to worry about whether it's Chinese or English characters.
About "mysql how to replace part of the field" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.