有没有办法从所有值的特定列中删除所有空格?
Answers:
替换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
TRIM
仅从字符串的开头和结尾删除空格。
table
SET col_name
= REPLACE(col_name
,'\ t','')
table
set col_name = REPLACE(col_name,'\ r','');