开发者

Check spaces in mysql field

开发者 https://www.devze.com 2023-01-23 21:09 出处:网络
select name from emp_profile开发者_JS百科; Result: tom@rj6.com In the above result how to determine whether there are trailing spaces in it or notRTRIM() removes trailing spaces.
 select name from emp_profile开发者_JS百科;

    Result:
     tom@rj6.com

In the above result how to determine whether there are trailing spaces in it or not


RTRIM() removes trailing spaces.

If RTRIM(name) varies from name, there are trailing spaces in the field.

Related functions are LTRIM() (trims starting spaces) and TRIM() (both sides)

As a side note, I would recommend removing trailing spaces (and other invalid data) during input time on application level, not in the database.


If name is a char field it wil not have trailing spaces as far as I can ascertain varchar's do have trailing spaces.

An easy way to check for trailing whitespace to check the length against the trimmed length. rtrim()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号