pgSQL中position函数的用法实现包含关系

发布时间 2023-05-29 10:45:24作者: 苦逼vs猴子
函数用法:POSITION(substring in string)
substring参数是您要查找的字符串
POSITION()函数返回一个整数。该整数表示子字符串在字符串中的位置。如果在字符串中未找到子字符
串,则POSITION()函数将返回零(0),否则返回子字符串在字符串中的下标,测,1:select 
position('warning' in 'warning,handle,cases,caseinfo'),运行后返回1,测,2:select position('handle' 
in 'warning,handle,cases,caseinfo'),运行后返回9,即handle在字符串中的位置下标为9。如果子字符
串或字符串参数为null,则返回null。
例如:position('warning' in 'warning,handle,cases,caseinfo')>0
从warning,handle,cases,caseinfo中找warning的位置,如果大于0,则表示存在,否则不存在。

文章来源:https://blog.csdn.net/weixin_43230284/article/details/123271686