Red Devil
Red Devil

Reputation: 2393

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.

How to achieve that?

Upvotes: 0

Views: 45

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1269513

Depending on your database you can use trim(), ltrim()/rtrim(), or replace():

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

Upvotes: 2

Felix Pamittan
Felix Pamittan

Reputation: 31879

You can use the LTRIM and RTRIM functions to remove trailing and leading spaces.

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

Upvotes: 0

Related Questions