简体   繁体   English

从行中删除空格

[英]Removing blank spaces from the rows

I have a column as name which is having a results like. 我有一个列作为名称,其结果类似。

name
ABC
XYZ
   ader
fer

I want to remove the blank space before ader and it should print in the output like ader. 我想删除ader之前的空格,它应该像ader一样在输出中打印。

How to achieve that? 如何实现呢?

Depending on your database you can use trim() , ltrim() / rtrim() , or replace() : 根据您的数据库,您可以使用trim()ltrim() / rtrim()replace()

select replace(name, ' ', '')
select trim(name, ' ')
select ltrim(rtrim(name))

You can use the LTRIM and RTRIM functions to remove trailing and leading spaces. 您可以使用LTRIMRTRIM函数删除尾部和前导空格。

SELECT
    RTRIM(LTRIM(name)) AS name
FROM yourTable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM