mysql replace用法

1.replace into
replace into table (id,name) values('1','aa'),('2','bb')
此语句的作用是向表table中插入两条记录。如果主键id为1或2不存在
就相当于
insert into table (id,name) values('1','aa'),('2','bb')
如果存在相同的值则不会插入数据

2.replace(object,search,replace)

把object中出现search的全部替换为replace

select replace('www.jb51.net','w','Ww')--->WwWwWw.jb51.net

例:把表table中的name字段中的aa替换为bb

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

相关文章:

  • 2021-05-24
  • 2021-12-14
  • 2022-01-08
  • 2022-12-23
  • 2021-08-08
猜你喜欢
  • 2021-10-30
  • 2021-11-09
相关资源
相似解决方案