-- 示例代码:替换 MySQL 字段中的某个字符
-- 假设我们有一个表 `users`,其中有一个字段 `email`,我们想要将所有 `@example.com` 替换为 `@newdomain.com`
UPDATE users
SET email = REPLACE(email, '@example.com', '@newdomain.com')
WHERE email LIKE '%@example.com';
-- 解释:
-- 1. `REPLACE(column, old_str, new_str)` 函数用于将列中的指定字符串替换为新的字符串。
-- 2. `WHERE email LIKE '%@example.com'` 确保只更新包含 `@example.com` 的记录,避免不必要的更新操作。
上一篇:linux 卸载mysql
下一篇:mysql 时间函数
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站