locate
功能
適用于: Databricks SQL Databricks Runtime
傳回位置 之後第一次出現 substr
str
的位置 pos
。 此函式與 position 函式同義。
語法
locate(substr, str [, pos] )
參數
subtr
:STRING 運算式。str
:STRING 運算式。pos
:選擇性的 INTEGER 運算式。
返回
整數。
指定的 pos
和 傳回值是以 1 為基礎。
如果 pos
從 substr
的開頭 str
搜尋了 ,則為 。
如果 pos
小於 1,則結果為 0。
例子
> SELECT locate('bar', 'abcbarbar');
4
> SELECT locate('bar', 'abcbarbar', 5);
7