kristain

博客园 首页 新随笔 联系 订阅 管理

mysql替换表的字段里面内容,如例子:

引用

mysql> select host,user from user  where user='user';
+-----------------------+----------+
| host                  | user     |
+-----------------------+----------+
| localhost.localdomain | testuser |
+-----------------------+----------+

update字段host的内容,把"main"改成"slave",用REPLACE

mysql> update user set host=REPLACE(host,'main','slave') where user='user';      
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host,user from user  where user='user';                            
+------------------------+----------+
| host                   | user     |
+------------------------+----------+
| localhost.localdoslave | testuser |
+------------------------+----------+
posted on 2012-06-05 09:10  kristain  阅读(320)  评论(0编辑  收藏  举报