Quantcast
Channel: PHP+MySQL –任鸟飞— 专注网页设计 海阔凭鱼跃 天高任鸟飞
Viewing all articles
Browse latest Browse all 28

MySQL replace() 函数批量替换数据库中指定字符串

$
0
0

MySQL 批量更换指定字符串的函数:replace(str,old_string,new_string),比如全站开启https时,需要将原有的http替换为https就可以使用replace函数,直接在数据库中执行replace函数即可,简单快捷。

replace(str,old_string,new_string) 参数说明:

  • str:字段
  • old_string:旧的字符串
  • new_string:新的字符串

例如 posts表内content字段中http替换为https的语句:

UPDATE posts SET content=replace(content, ‘http’,’https’)

 


Viewing all articles
Browse latest Browse all 28

Trending Articles