Site icon TestingDocs.com

MySQL TRIM Function

Overview

In this tutorial, we will learn about MySQL TRIM function with some examples. This function removes the trim character/string from the beginning or at the end of the given string.

Syntax

The general syntax of the function is as follows:

TRIM([LEADING | TRAILING | BOTH <trim_string> FROM ] <string>)

Examples

mysql> SELECT TRIM(‘ MySQL Tutorials ‘);
+—————————————————+
| TRIM(‘ MySQL Tutorials ‘) |
+—————————————————+
| MySQL Tutorials |
+—————————————————+
1 row in set (0.00 sec)

mysql> SELECT TRIM(LEADING ‘a’ FROM ‘aaaaMySQL Tutorials’);
+———————————————-+
| TRIM(LEADING ‘a’ FROM ‘aaaaMySQL Tutorials’) |
+———————————————-+
| MySQL Tutorials |
+———————————————-+
1 row in set (0.01 sec)

 

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version