Reputation: 27
I have a table "User" with 5 columns 'id','firstname','lastname','age','email'.
Is it possible to execute this sql command?
SELECT LTRIM(RTRIM(firstname,lastname,email)) FROM User
All i need to select is the 3 columns that are trimmed.
Upvotes: 1
Views: 3980
Reputation: 3844
Use this:
SELECT
LTRIM(RTRIM(FirstName)) AS FirstName,
LTRIM(RTRIM(LastName)) AS LastName,
LTRIM(RTRIM(Email)) AS Email
FROM User
You need to do TRIM all the column separately.
Upvotes: 1
Reputation: 12772
You need to trim each field separately
select ltrim(rtrim(firstname)), ltrim(rtrim(lastname)), ltrim(rtrim(email))
from User
Upvotes: 3
Reputation: 1269483
You have to handle each column separately, as in:
SELECT LTRIM(RTRIM(firstname)) as firstname,
LTRIM(RTRIM(lastname)) as lastname,
LTRIM(RTRIM(email)) as email
FROM [User]
Upvotes: 2