Skip to content

Commit

Permalink
TiDB supports MID(str, pos[, len])
Browse files Browse the repository at this point in the history
Signed-off-by: Aolin <[email protected]>
  • Loading branch information
Oreoxmt committed Sep 18, 2024
1 parent fe298c6 commit a402a0c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions functions-and-operators/string-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1425,15 +1425,15 @@ SELECT MAKE_SET(b'111','foo','bar','baz');

### [`MID()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_mid)

`MID(str,pos,len)` 函数返回从指定的 `pos` 位置开始的长度为 `len` 的子字符串。
`MID(str, pos[, len])` 函数返回从指定的 `pos` 位置开始的长度为 `len` 的子字符串。

如果任一参数为 `NULL`,该函数将返回 `NULL`
从 v8.4.0 开始,TiDB 支持该函数的两参数版本,即 `MID(str, pos)`。如果未指定 `len`,则返回从指定的 `pos` 位置到字符串末尾的所有字符

TiDB 不支持该函数的两参数版本。更多信息,请参见 [#52420](https://github.com/pingcap/tidb/issues/52420)
如果任一参数为 `NULL`,该函数将返回 `NULL`

示例:

在以下示例中,`MID()` 返回给定的字符串中从第二个字符 (`b`) 开始的长度为 `3` 个字符的的子字符串
在以下示例中,`MID()` 返回给定的字符串中从第二个字符 (`b`) 开始的长度为 `3` 个字符的子字符串

```sql
SELECT MID('abcdef',2,3);
Expand All @@ -1448,6 +1448,21 @@ SELECT MID('abcdef',2,3);
1 row in set (0.00 sec)
```

在以下示例中,`MID()` 返回给定的字符串中从第二个字符 (`b`) 开始到字符串末尾的子字符串。

```sql
SELECT MID('abcdef',2);
```

```
+-------------------+
| MID('abcdef',2) |
+-------------------+
| bcdef |
+-------------------+
1 row in set (0.00 sec)
```

### [`NOT LIKE`](https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_not-like)

否定简单模式匹配。
Expand Down

0 comments on commit a402a0c

Please sign in to comment.