-- 使用 LOCATE 函数查找字符串中某个字符的位置
-- 语法: LOCATE(substring, string [, position])
-- 参数:
-- substring: 要查找的子字符串
-- string: 原始字符串
-- position: 可选参数,从指定位置开始查找
-- 示例代码:
SELECT LOCATE('o', 'hello world');
-- 输出: 5,表示 'o' 在字符串 'hello world' 中的位置是第 5 个字符
SELECT LOCATE('o', 'hello world', 6);
-- 输出: 8,表示从第 6 个字符开始查找,'o' 的位置是第 8 个字符
SELECT LOCATE('z', 'hello world');
-- 输出: 0,表示 'z' 不在字符串 'hello world' 中
上一篇:mysql string
下一篇:mysql 修改字符集
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站