如何使用trim()并更新mysql中的所有行

时间:2015-05-27 15:30:29

标签: php mysql

我在mysql中有一个大表。我记录中的字符串周围是浪费空间,如下所示:

+---------------------------+----------------------------+
|        anything           |           anything         |
----------------------------------------------------------
|        anything           |           anything         |
+---------------------------+----------------------------+

现在我想要这个:

+--------+--------+
|anything|anything|
-------------------
|anything|anything|
+--------+--------+

实际上我想对所有行使用trim()并更新它们。我怎么能这样做?

1 个答案:

答案 0 :(得分:4)

如以下几条评论中所述:

UPDATE sometable SET column1 = TRIM(column1), column2 = TRIM(column2);