Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

mysql替换字符串函数replace

作者:冷血杀手   发布日期:2026-05-15   浏览:130

-- 使用 REPLACE 函数替换字符串中的指定子字符串
-- 语法: REPLACE(str, from_str, to_str)
-- 参数:
-- str: 原始字符串
-- from_str: 要被替换的子字符串
-- to_str: 用来替换的新子字符串

-- 示例 1: 替换 'hello' 中的 'l' 为 'L'
SELECT REPLACE('hello', 'l', 'L');
-- 结果: 'heLLo'

-- 示例 2: 替换 'www.example.com' 中的 'example' 为 'test'
SELECT REPLACE('www.example.com', 'example', 'test');
-- 结果: 'www.test.com'

-- 示例 3: 如果 from_str 不存在于 str 中,则返回原始字符串
SELECT REPLACE('hello world', 'bye', 'hi');
-- 结果: 'hello world'

上一篇:mysql lower_case_table_names

下一篇:mysql 正则

大家都在看

mysql二级索引

mysqlavg函数保留小数

mysql显示表内容

mysql经纬度距离计算

mysql 加密

存储过程mysql

mysql 1265

mysql with语句

mysql时间加减

mysql查询表名,模糊匹配

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站