一尘不染

MySQL从整个列中删除所有空格

mysql

有没有办法从所有值的特定列中删除所有空格?


阅读 325

收藏
2020-05-17

共1个答案

一尘不染

替换all spaces

UPDATE `table` SET `col_name` = REPLACE(`col_name`, ' ', '')

删除所有tabs字符:

UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\t', '' )

删除所有new line字符:

UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\n', '')

http://dev.mysql.com/doc/refman/5.0/zh-CN/string-
functions.html#function_replace

删除first and last space(s)列:

UPDATE `table` SET `col_name` = TRIM(`col_name`)

http://dev.mysql.com/doc/refman/5.0/zh-CN/string-
functions.html#function_trim

2020-05-17