简体   繁体   中英

Trimming both 0 and trailing/leading spaces doesn't give results - MySQL

I have the below situation in the database where accounts could have leading 0 and white spaces.

在此处输入图片说明

If I use TRIM(TRIM(LEADING '0' FROM account_ref)) as account_ref_trimmed , I get:

在此处输入图片说明

Question, is it correct to put trim inside the trim? Secondly, why in row 5, there is still a leading 0?

Trim the spaces and then the zeroes:

TRIM(LEADING '0' FROM TRIM(account_ref))

When you try to trim the zeroes first, any values that have spaces at the beginning and then zeroes will only be trimmed off of spaces.
As for your question about precedence it is indicated by the nested parentheses.

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