要删除尾随空间,请RTRIM()
在MySQL中使用。让我们首先创建一个表-
mysql> create table DemoTable -> ( -> FirstName varchar(50) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('John '); mysql> insert into DemoTable values('Chris '); mysql> insert into DemoTable values(' David '); mysql> insert into DemoTable values('Mike');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-------------------+ | FirstName | +-------------------+ | John | | Chris | | David | | Mike | +-------------------+ 4 rows in set (0.00 sec)
这是使用以下命令删除尾随空格的MySQL查询RTRIM()
:
mysql> select rtrim(FirstName) as FirstName from DemoTable;
这将产生以下输出-
+-------------+ | FirstName | +-------------+ | John | | Chris | | David | | Mike | +-------------+ 4 rows in set (0.00 sec)