How to remove tabs at start and end of varchar field in MySQL?

前端 未结 4 1453
夕颜
夕颜 2021-01-04 03:05

I\'ve got a field in a mysql db that\'s a varchar(255). I\'ve looked at trim() to remove leading and trailing whitespace, but it seems to only handle spaces, not tab charac

相关标签:
4条回答
  • 2021-01-04 03:18

    You can use replace with either \t or CHAR(9):

    UPDATE mytable SET email = REPLACE(TRIM(email), '\t', '');
    
    0 讨论(0)
  • 2021-01-04 03:34

    You can still use the TRIM function, and specify the character to be trimmed:

    UPDATE mytable SET email = TRIM(CHAR(9) FROM TRIM(email));
    
    0 讨论(0)
  • 2021-01-04 03:39

    The TRIM function provides a good solution for your problem. Just use some like this above:

    UPDATE yourtable SET your_field = TRIM(CHAR(9) FROM TRIM(your_field));
    
    0 讨论(0)
  • 2021-01-04 03:40

    Have you tried this?

    UPDATE mytable SET email = REPLACE(TRIM(email), CHAR(9), '')
    
    0 讨论(0)
提交回复
热议问题