From 3fc7142e5afac5fcd1177790859ee2a81e4893b0 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 28 Mar 2024 14:42:48 +0800 Subject: [PATCH] Add LPAD() example --- functions-and-operators/string-functions.md | 45 +++++++++++++++++++++ tidb-roadmap.md | 1 + 2 files changed, 46 insertions(+) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index d6c9f6bf1ad7b..16dcd546bf26b 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1162,6 +1162,51 @@ SELECT LOWER(-012); Return the string argument, left-padded with the specified string. +```sql +SELECT LPAD('TiDB',8,'>'); +``` + +``` ++--------------------+ +| LPAD('TiDB',8,'>') | ++--------------------+ +| >>>>TiDB | ++--------------------+ +1 row in set (0.00 sec) +``` + +In the example above the string "TiDB" is left padded until 8 characters with 4 `>` characters. + +```sql +SELECT LPAD('TiDB',2,'>'); +``` + +``` ++--------------------+ +| LPAD('TiDB',2,'>') | ++--------------------+ +| Ti | ++--------------------+ +1 row in set (0.00 sec) +``` + +In the example above the string "TiDB" is left padded until 2 characters with `>` characters. The result is "Ti". This shows that the string in the first argument will be truncated if it is longer than the second argument. + +```sql +SELECT LPAD('TiDB',-2,'>'); +``` + +``` ++---------------------+ +| LPAD('TiDB',-2,'>') | ++---------------------+ +| NULL | ++---------------------+ +1 row in set (0.00 sec) +``` + +In the example above the string "TiDB" is left padded until -2 characters with `>` characters. The result is NULL as the second argument is negative. + ### [`LTRIM()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ltrim) Remove leading spaces. diff --git a/tidb-roadmap.md b/tidb-roadmap.md index a115531fb66f6..8e2c5d6fa5c72 100644 --- a/tidb-roadmap.md +++ b/tidb-roadmap.md @@ -227,6 +227,7 @@ You might have been waiting on some items from the last version. The following l ## Recently shipped +- [TiDB 8.0.0 Release Notes](https://docs.pingcap.com/tidb/v8.0/release-8.0.0) - [TiDB 7.6.0 Release Notes](https://docs.pingcap.com/tidb/v7.6/release-7.6.0) - [TiDB 7.5.0 Release Notes](https://docs.pingcap.com/tidb/v7.5/release-7.5.0) - [TiDB 7.4.0 Release Notes](https://docs.pingcap.com/tidb/v7.4/release-7.4.0)