当前位置:网站首页>MySQL replacement field part content

MySQL replacement field part content

2022-07-06 12:17:00 wx5caecf2ed0645


[mysql]replace Usage of ( Replace part of a field )

[mysql]replace Usage of

1.replace into

          replace into table (id,name) values('1','aa'),('2','bb')

          The function of this statement is to table table Insert two records . If the primary key id by 1 or 2 Non existence is equivalent to

          insert into table (id,name) values('1','aa'),('2','bb')

          If the same value exists, no data will be inserted

2.replace(object,search,replace)

          hold object It appears that search Replace all of them with replace

          select replace('www.163.com','w','Ww')--->WwWwWw.163.com

          example : Keep watch table Medium name In the field aa Replace with bb

          update table set name=replace(name,'aa','bb')

3.UPDATE Update part of a field

Now the field of a record is “abcdefg", Now I just want to put... In this field c Change it to C,update How should the statement be written

update Table name set Field 1 = replace( Field 1,'c','C')


原网站

版权声明
本文为[wx5caecf2ed0645]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131547076865.html