I am new to postgresql guys. I tried to use substring function, while trying some examples I've noticed "awkward" behaviour that I didn't understand. Consider the following scenarios:
select substring('123456',1,3) returns 123 (which is logical for me)
select substring('123456',0,1) returns nothing (I don't know why!)
select substring('123456',-1,2) returns nothing too!
Question: Can someone explain how does postgresql substring function behave when we give it 0 or negative values for position.
select substring('123456', -1, 3)return, out of interest? I suspect the fact that the indexes are 1-based is relevant here... maybe anything "before" position 1 is just assumed not to exist?SUBSTR: Refer discussion here postgresql.org/message-id/12803.1168804636%40sss.pgh.pa.us