zoukankan      html  css  js  c++  java
  • mysql替换字段里数据内容部分字符串(亦可用于增加字段中的内容)

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

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

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

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

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

    由查询结果到,数据已经更新成功

  • 相关阅读:
    leetcode643.滑动窗口例题
    BZOJ4195 离散化+并查集
    luogu线性表刷题
    2021-5-29 周报博客
    2021-5-28 日报博客
    2021-5-27 日报博客
    2021-5-26 日报博客
    2021-5-25 日报博客
    2021-5-24 日报博客
    梦断代码阅读笔记之二
  • 原文地址:https://www.cnblogs.com/chen-lhx/p/4015164.html
Copyright © 2011-2022 走看看