Postgresql常用语句-截取字符串

函数:substring(‘hello@163.com’, start, count);
参数1:字符串,参数2:起始位置,参数3:count
注意:start的位置, count值的区别

查询子字符串hello

例子1. start=0,count=6
SELECT substring('hello@163.com',0,6);
--结果:hello

例子2. start=1,count=5
SELECT substring('hello@163.com',1,5);
--结果:hello

例子3. start=2,count=5
SELECT substring('hello@163.com',2,5);
--结果:ello@