Maison > base de données > tutoriel mysql > le corps du texte

我们如何从 MySQL 中的字符串中消除前导和尾随空格字符?

王林
Libérer: 2023-08-30 11:49:02
avant
939 人浏览过

我们如何从 MySQL 中的字符串中消除前导和尾随空格字符?

MySQL LTRIM() 和 RTRIM() 函数可用于消除字符串中的前导空格和尾随空格。

MySQL LTRIM() 函数用于删除字符串中的前导空格字符。其语法如下 -

语法

LTRIM(String)
Copier après la connexion

此处,String 是作为参数传递的字符串,其前导空格字符将被删除。

示例

mysql> Select LTRIM(' Hello');
+--------------------+
| LTRIM(' Hello')    |
+--------------------+
| Hello              |
+--------------------+
1 row in set (0.00 sec)
Copier après la connexion

MySQL RTRIM() 函数用于从字符串中删除尾随空格字符。其语法如下 -

语法

RTRIM(String)
Copier après la connexion

此处,String 是作为参数传递的字符串,其尾随空格字符将被删除。

示例

mysql> Select RTRIM('Hello ');
+----------------------+
| RTRIM('Hello ')      |
+----------------------+
| Hello                |
+----------------------+
1 row in set (0.05 sec)
Copier après la connexion

以上是我们如何从 MySQL 中的字符串中消除前导和尾随空格字符?的详细内容。更多信息请关注PHP中文网其他相关文章!

source:tutorialspoint.com
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!