This is an automated email from the ASF dual-hosted git repository.

zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new b785aaad037 [doc](function)add docs for position and substring (#2869)
b785aaad037 is described below

commit b785aaad03701f8cb29ea7f689de090d26421a79
Author: admiring_xm <[email protected]>
AuthorDate: Tue Sep 30 17:12:04 2025 +0800

    [doc](function)add docs for position and substring (#2869)
    
    ## Versions
    
    - [x] dev
    - [ ] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    ## Languages
    
    - [x] Chinese
    - [x] English
    
    ## Docs Checklist
    
    - [ ] Checked by AI
    - [ ] Test Cases Built
    
    Co-authored-by: zclllyybb <[email protected]>
---
 .../scalar-functions/string-functions/position.md  | 49 ++++++++++++++++++++++
 .../scalar-functions/string-functions/substring.md | 26 ++++++++++++
 .../scalar-functions/string-functions/position.md  | 47 +++++++++++++++++++++
 .../scalar-functions/string-functions/substring.md | 26 ++++++++++++
 sidebars.json                                      |  1 +
 5 files changed, 149 insertions(+)

diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/position.md 
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/position.md
new file mode 100644
index 00000000000..3d8fcd57c57
--- /dev/null
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/position.md
@@ -0,0 +1,49 @@
+---
+{
+    "title": "POSITION",
+    "language": "en"
+}
+---
+
+## Description
+
+The POSITION function is used to find the position of a substring within a 
string (counting from 1).  
+
+If the substring is not found, the function returns 0.
+
+## Syntax
+
+```sql
+POSITION ( <substr> IN <str> )
+
+POSITION ( <substr>, <str> [, <pos>] )
+```
+
+## Parameters
+
+| Parameter | Description                                                      
                          |
+| --------- | 
------------------------------------------------------------------------------------------
 |
+| `substr`  | The substring to search for                                      
                          |
+| `str`     | The string to be searched                                        
                          |
+| `pos`     | If this parameter is specified, the position of substr is 
searched from the string starting with the pos subscript |
+
+## Return value
+
+The position of substr in str (counting from 1).
+If substr is not found, returns 0.
+
+```sql
+SELECT POSITION('bar' IN 'foobarbar'), 
+       POSITION('bar', 'foobarbar'),
+       POSITION('bar', 'foobarbar', 5),
+       POSITION('xbar', 'foobar');
+```
+
+```text
+
++----------------------------------+--------------------------------+-----------------------------------+----------------------------------+
+| position('bar' in 'foobarbar')   | position('bar', 'foobarbar')   | 
position('bar', 'foobarbar', 5)   | position('xbar', 'foobar')       |
++----------------------------------+--------------------------------+-----------------------------------+----------------------------------+
+|                                4 |                              4 |          
                       7 |                                0 |
++----------------------------------+--------------------------------+-----------------------------------+----------------------------------+
+```
diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md 
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
index 9236a0e78a3..6000ec772e9 100644
--- 
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
@@ -17,6 +17,8 @@ SUBSTR
 
 ```sql
 SUBSTRING(<str>, <pos> [, <len>])
+
+SUBSTRING(<str> FROM <pos> [FOR <len>])
 ```
 
 ## Parameters
@@ -97,4 +99,28 @@ SELECT substring('abc1def', 2, 2);
 +-----------------------------+
 | bc                          |
 +-----------------------------+
+```
+
+6. Using from and for
+```sql
+SELECT substring('foobarbar' FROM 4 FOR 3);
+```
+```text
++-------------------------------------+
+| substring('foobarbar' FROM 4 FOR 3) |
++-------------------------------------+
+| bar                                 |
++-------------------------------------+
+```
+
+7. Using from
+```sql
+SELECT substring('foobarbar' FROM 4);
+```
+```text
++-------------------------------+
+| substring('foobarbar' FROM 4) |
++-------------------------------+
+| barbar                        |
++-------------------------------+
 ```
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/position.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/position.md
new file mode 100644
index 00000000000..169a2aaadb8
--- /dev/null
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/position.md
@@ -0,0 +1,47 @@
+---
+{
+    "title": "POSITION",
+    "language": "zh-CN"
+}
+---
+
+## 描述
+
+POSITION 函数用于查找子字符串在字符串中的位置(从 1 开始计数)。如果指定第 3 个参数 pos,则从 str 以 pos 
下标开始的字符串处开始查找 substr 出现的位置。如果没有找到,返回 0
+
+## 语法
+
+```sql
+POSITION ( <substr> IN <str> )
+
+POSITION ( <substr>, <str> [, <pos>] )
+```
+
+## 参数
+
+| 参数       | 说明                                              |
+| -------- | ----------------------------------------------- |
+| `substr` | 需要查找的子字符串                                       |
+| `str`    | 需要被查找的字符串                                       |
+| `pos`    | 如果指定了此参数,则 str 以 pos 下标开始的字符串处开始查找 substr 出现的位置 |
+
+## 返回值
+
+substr 在 str 中出现的位置(从 1 开始计数)。如果没有找到,返回 0
+
+## 举例
+
+```sql
+SELECT POSITION('bar' IN 'foobarbar'), 
+       POSITION('bar', 'foobarbar'),
+       POSITION('bar', 'foobarbar', 5),
+       POSITION('xbar', 'foobar');
+```
+
+```text
++----------------------------------+--------------------------------+-----------------------------------+----------------------------------+
+| position('bar' in 'foobarbar')   | position('bar', 'foobarbar')   | 
position('bar', 'foobarbar', 5)   | position('xbar', 'foobar')       |
++----------------------------------+--------------------------------+-----------------------------------+----------------------------------+
+|                                4 |                              4 |          
                       7 |                                0 |
++----------------------------------+--------------------------------+-----------------------------------+----------------------------------+
+```
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
index babdcfbd4dc..a3380190ea8 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
@@ -17,6 +17,8 @@ SUBSTR
 
 ```sql
 SUBSTRING(<str>, <pos> [, <len>])
+
+SUBSTRING(<str> FROM <pos> [FOR <len>])
 ```
 
 ## 参数
@@ -97,4 +99,28 @@ SELECT substring('abc1def', 2, 2);
 +-----------------------------+
 | bc                          |
 +-----------------------------+
+```
+
+6. 使用 from 和 for
+```sql
+SELECT substring('foobarbar' FROM 4 FOR 3);
+```
+```text
++-------------------------------------+
+| substring('foobarbar' FROM 4 FOR 3) |
++-------------------------------------+
+| bar                                 |
++-------------------------------------+
+```
+
+7. 使用 from
+```sql
+SELECT substring('foobarbar' FROM 4);
+```
+```text
++-------------------------------+
+| substring('foobarbar' FROM 4) |
++-------------------------------+
+| barbar                        |
++-------------------------------+
 ```
\ No newline at end of file
diff --git a/sidebars.json b/sidebars.json
index 20bdf3d3a03..dccc67008b2 100644
--- a/sidebars.json
+++ b/sidebars.json
@@ -1280,6 +1280,7 @@
                                         
"sql-manual/sql-functions/scalar-functions/string-functions/overlay",
                                         
"sql-manual/sql-functions/scalar-functions/string-functions/parse-data-size",
                                         
"sql-manual/sql-functions/scalar-functions/string-functions/parse-url",
+                                        
"sql-manual/sql-functions/scalar-functions/string-functions/position",
                                         
"sql-manual/sql-functions/scalar-functions/string-functions/printf",
                                         
"sql-manual/sql-functions/scalar-functions/string-functions/protocol",
                                         
"sql-manual/sql-functions/scalar-functions/string-functions/quote",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to