简体   繁体   中英

Trim spaces from a field when selecting

I'm trying to remove spaces from a field (before and after the name)

SELECT TRIM(name) AS new_name FROM users;

But it doesn't do anything, and as I have looked at MySQL dev pages, the query looks right. Am I missing anything?

Have also tried both LTRIM & RTRIM but same result.

Ok, I placed a dot before and after each row, than used

SUBSTRING_INDEX

to extract the name only from the result, that way I got what I needed. Thanks everybody for your answers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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