共用方式為


locate 功能

適用于:核取標示為是 Databricks SQL 檢查標示為是 Databricks Runtime

傳回位置 之後第一次出現 substrstr 的位置 pos 。 此函式與 position 函式同義。

語法

locate(substr, str [, pos] )

參數

  • subtr:STRING 運算式。
  • str:STRING 運算式。
  • pos:選擇性的 INTEGER 運算式。

返回

整數。

指定的 pos 和 傳回值是以 1 為基礎。 如果 possubstr 的開頭 str 搜尋了 ,則為 。 如果 pos 小於 1,則結果為 0。

例子

> SELECT locate('bar', 'abcbarbar');
 4
> SELECT locate('bar', 'abcbarbar', 5);
 7