PostgreSQL 判断字符串中是否含有指定字符
PostgreSQL About 593 words正则表达式
使用~符号,A ~ B表示:A中是否包含B。
返回值类型:boolean。
示例:查询test_column列中的值包含abc字符串的记录。
select * from test where test_column ~ 'abc';
position 函数
position(substring in string)。
position('B' in 'A'):B字符串在A中的索引位置。
返回值类型:int。
示例:查询aa字符串在abcd字符串中的索引位置,返回0表示aa没有出现在abcd中。
select position('aa' in 'abcd');
示例:查询b字符串在abcd字符串中的索引位置,返回2表示b出现在abcd中的第2个位置。
select position('b' in 'abcd');
strpos 函数
strpos(string, substring)。
strpos('A', 'B'):B字符串在A中的索引位置。
返回值类型:int。
示例:查询aa字符串在abcd字符串中的索引位置,返回0表示aa没有出现在abcd中。
select strpos('abcd', 'aa');
示例:查询c字符串在abcd字符串中的索引位置,返回3表示c出现在abcd中的第3个位置。
select strpos('abcd', 'c');
Views: 1,976 · Posted: 2023-11-08
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...