目录

MySQL INSTR() 函数

示例

在字符串"91xjr.com"中搜索"3",并返回位置:

SELECT INSTR("91xjr.com", "3") AS MatchPosition;
亲自试一试 »

定义和用法

INSTR() 函数返回一个字符串在另一个字符串中第一次出现的位置。

该函数执行不区分大小写的搜索。

语法

INSTR( string1, string2)

参数值

Parameter Description
string1 Required. The string that will be searched
string2 Required. The string to search for in string1. If string2 is not found, this function returns 0

技术细节

工作于: 从 MySQL 4.0 开始

更多示例

示例

在字符串"91xjr.com"中搜索"COM",并返回位置:

SELECT INSTR("91xjr.com", "COM") AS MatchPosition;
亲自试一试 »

示例

在 CustomerName 列中搜索"a",并返回位置:

SELECT INSTR(CustomerName, "a")
FROM Customers;
亲自试一试 »