开发者

Check spaces in mysql field

 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜