sql查找字段中某字符的位置

1.创建测试表,

createtabletest_student(idnumber,remarkvarchar2(20));

2

insertintotest_studentvalues(1001,1014133);

insertintotest_studentvalues(1002,2014131);

insertintotest_studentvalues(1003,3014132);

insertintotest_studentvalues(1004,4010135);

提交;

3.selectt.*,instr(remark,'10')locfromtest_studentt;

可以查到一些记录,没有10条,所以返回值为0;

sql中取指定字符串出现位置的方法

哪个数据库?如果是Oracle,selectsubstr('123.456.789',-3,3)fromdual;--789selectsubstr('123.456.789',-3,2)fromdual;--78负数,反向拦截sqlserverwrite('123.456',3)如果确定了最后三位数字。

MSSQLServer有没有查找字符串位置的函数

SQL使用CHARINDEX函数来查找字符串的位置。

CHARINDEX函数在字符周期中搜索字符或字符串。

语法

CHARINDEX(表达式1,表达式2,[起始位置])

参数

表达式1

表达式1

包含要查找的字符顺序的表达式。
表达式1是被分类为短字符数据类型的表达式。

表达式2

表达式,通常是一列,用于搜索特定序列。
Expression2属于String数据类型分类。

start_location

在Expression2中搜索Expression1时起始字符的位置。
如果未指定start_location而是负数或零,则搜索从表达式2的起始位置开始。

返回类型

int

示例: