MySQL从整个列中删除所有空格 [英] MySQL remove all whitespaces from the entire column
本文介绍了MySQL从整个列中删除所有空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从特定列中删除所有值的所有空格?
Is there a way to remove all whitespaces from a specific column for all values?
推荐答案
替换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
这篇关于MySQL从整个列中删除所有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文