Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1014 Bytes

File metadata and controls

34 lines (25 loc) · 1014 Bytes
description
Returns the position of the first occurrence of a substring within another string

POSITION

Syntax

POSITION(substr string IN expression string) → integer

  • substr: The substring to search for in the expression.
  • expression: The input expression to search.

Examples

{% code title="POSITION example" %}

SELECT POSITION('an' in 'banana')
-- 2

{% endcode %}

{% code title="POSITION example" %}

SELECT POSITION('no' in 'banana')
-- 0

{% endcode %}

Usage Notes

Searches for the first occurrence of the first argument in the second argument and if found, returns the position the of the first argument in the second argument. The first character in a string is position 1. Returns 0 if the substring is not found in the expression.