Skip to content
Advertisement

Why does strpos, position, charindex return 1 when empty substring is passed

Why do all three of these return a value of 1 in redshift?

select strpos('X', '')
select position('' in 'X')
select charindex('', 'X')

Advertisement

Answer

Because the empty string is the very first part of all strings.

7 People found this is helpful
Advertisement