Files
doris/docs/zh-CN/sql-reference/sql-functions/string-functions/like/like.md
EmmyMiao87 15c5896f41 [Docs] Add like, regexp function documents (#6182)
* [Docs] Add like, regexp function documents

* Reconstruct

* Fix compile error
2021-07-15 13:16:21 +08:00

1.6 KiB

title, language
title language
like zh-CN

like

description

syntax

'BOOLEAN like(VARCHAR str, VARCHAR pattern)'

对字符串 str 进行模糊匹配,匹配上的则返回 true,没匹配上则返回 false。

like 匹配/模糊匹配,会与 % 和 _ 结合使用。

'a' // 精准匹配,和 = 效果一致。 '%a' // 以a结尾的数据 'a%' // 以a开头的数据 '%a%' // 含有a的数据 'a' // 三位且中间字母是 a 的 'a' // 两位且结尾字母是 a 的 'a' // 两位且开头字母是 a 的

example

// 返回 k1 字符串中包含 a 的数据
mysql > select k1 from test where k1 like '%a%';
+-------+
| k1    |
+-------+
| a     |
| bab   |
+-------+

// 返回 k1 字符串中等于 a 的数据
mysql > select k1 from test where k1 like 'a';
+-------+
| k1    |
+-------+
| a     |
+-------+

keyword

LIKE