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

yiguolei 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 2a6c888d40c update like with escape clause doc (#2552)
2a6c888d40c is described below

commit 2a6c888d40c2b89261c6dbf7f0022f9130717a59
Author: Pxl <[email protected]>
AuthorDate: Wed Jun 25 18:26:21 2025 +0800

    update like with escape clause doc (#2552)
    
    ## Versions
    
    - [x] dev
    - [ ] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    ## Languages
    
    - [x] Chinese
    - [x] English
    
    ## Docs Checklist
    
    - [ ] Checked by AI
    - [ ] Test Cases Built
---
 .../pattern-matching-operators.md                  | 36 +++++++++++++++++++-
 .../pattern-matching-operators.md                  | 39 ++++++++++++++++++++--
 2 files changed, 71 insertions(+), 4 deletions(-)

diff --git 
a/docs/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
 
b/docs/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
index 431906703ad..3ea651e7b00 100644
--- 
a/docs/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
+++ 
b/docs/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
@@ -23,13 +23,14 @@ The LIKE condition specifies a test involving pattern 
matching. The equality com
 The syntax is as follows:
 
 ```sql
-<char1> [ NOT ] LIKE <char2>
+<char1> [ NOT ] LIKE <char2> [ ESCAPE 'char_escape' ]
 ```
 
 Where:
 
 - `char1` is a character expression (such as a character column), known as the 
search value.
 - `char2` is a character expression, usually a string literal, known as the 
pattern.
+- `char_escape` (optional) is a character expression and must be a character 
of length 1 (under ascii encoding). It allows you to define escape characters, 
and if you do not provide char_escape, the default ' \ ' is an escape character.
 
 Both character expressions (`char1`, `char2`) can be any of CHAR, VARCHAR, or 
STRING data types. If they are different, Doris will convert them all to 
VARCHAR or STRING.
 
@@ -38,6 +39,39 @@ Patterns can include special pattern matching characters:
 - The underscore (`_`) in the pattern matches exactly one character in the 
value.
 - The percent sign (`%`) in the pattern can match zero or multiple characters 
in the value. The pattern `%` cannot match NULL.
 
+### Example
+
+
+```sql
+select "%a" like "\%_";
+```
+
+The result is as follows, because "%" is a special character, it needs to be 
escaped with "\%" to match correctly.
+
+```text
++-----------------+
+| "%a" like "\%_" |
++-----------------+
+|               1 |
++-----------------+
+```
+
+
+```sql
+select "%a" like "a%_" ESCAPE "a";
+```
+
+The difference from the previous example is that "a" is specified as the 
escape character.
+
+```text
++----------------------------+
+| "%a" like "a%_" ESCAPE "a" |
++----------------------------+
+|                          1 |
++----------------------------+
+```
+
+
 ### REGEXP (RLIKE)
 
 REGEXP is similar to the LIKE condition, differing in that REGEXP performs 
regular expression matching, rather than the simple pattern matching performed 
by LIKE. This condition uses a set of input characters defined by a character 
to evaluate strings.
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
index 2c5d7a1871b..2f29f8c9b65 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/operators/conditional-operators/pattern-matching-operators.md
@@ -23,13 +23,14 @@ LIKE 条件指定一个涉及模式匹配的测试。等值比较运算符(=
 语法如下:
 
 ```sql
-<char1> [ NOT ] LIKE <char2>
+<char1> [ NOT ] LIKE <char2> [ ESCAPE 'char_escape' ]
 ```
 
 其中:
 
-- char1 是一个字符表达式(如字符列),称为搜索值。
-- char2 是一个字符表达式,通常是一个字面量,称为模式。
+- char1 是一个字符表达式(如字符列),称为搜索串。
+- char2 是一个字符表达式,通常是一个字面量,称为模式串。
+- char_escape (可选) 是一个字符表达式,必须是一个长度为1的字符 ( ascii 编码下 )。 
它允许您定义转义字符,如果您不提供char_escape,则默认 ‘ \ ’是转义字符。
 
 所有字符表达式(char1、char2)都可以是 CHAR、VARCHAR 或 STRING 数据类型中的任何一种。如果它们不同,则 Doris 
会将它们全部转换为 VARCHAR 或者 STRING。
 
@@ -38,6 +39,38 @@ LIKE 条件指定一个涉及模式匹配的测试。等值比较运算符(=
 - 模式中的下划线 (_) 与值中的一个字符完全匹配。
 - 模式中的百分号 (%) 可以与值中的零个或多个字符匹配。模式 '%' 不能与 NULL 匹配。
 
+### 示例
+
+```sql
+select "%a" like "\%_";
+```
+
+结果如下,因为 "%" 是特殊字符,所以需要用 "\%" 进行转义才能正确匹配。
+
+```text
++-----------------+
+| "%a" like "\%_" |
++-----------------+
+|               1 |
++-----------------+
+```
+
+
+```sql
+select "%a" like "a%_" ESCAPE "a";
+```
+
+与之前的例子的区别在于有指定 "a" 作为转义字符。
+
+```text
++----------------------------+
+| "%a" like "a%_" ESCAPE "a" |
++----------------------------+
+|                          1 |
++----------------------------+
+```
+
+
 ### REGEXP(RLIKE)
 
 REGEXP 与 LIKE 条件类似,不同之处在于 REGEXP 执行正则表达式匹配,而不是 LIKE 
执行的简单模式匹配。此条件使用输入字符集定义的字符来评估字符串。


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

Reply via email to