zoukankan      html  css  js  c++  java
  • Mysql 字段字符串修改

    使用到的函数

    • CONCAT(str1,str2):字符连接函数
    • UPPER(str):将字符串改为大写字母
    • LOWER(str):将字符串改为小写字母
    • LENGTH(str):判定字符串长度
    • SUBSTRING(str,a,b):提取字段中的一段,从字符串str的第a位开始提取,提取b个字符
    • LEFT(str,n):提取字符串最左边的n个字符
    • RIGHT(str,n):提取字符串最右边的n个字符(该例未用到)

    分别举例如下:
    添加前缀:

    update `ecs_goods` set goods_name=concat('新中式',goods_name) where cat_id =4;

    添加后缀:

    update `ecs_goods` set goods_name=concat(goods_name,'新中式') where cat_id =4;

    去掉首字母

    update `ecs_goods`set goods_name=right(goods_name,length(goods_name)-1) where cat_id =4;
     
    替换 update 表名 set 字段名=REPLACE (字段名,'原来的值','要修改的值')
     
    生成删除表的语句
    SELECT CONCAT('delete from ',TABLE_NAME,';') AS a FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名' ;
     
  • 相关阅读:
    spring-boot4
    spring-boot3代码
    spring-boot3
    spring-boot2代码
    spring-boot2
    Java Socket编程
    eclipse项目中.classpath文件详解
    spring-boot1
    ASCII 在线转换器
    如何在Android开发中让你的代码更有效率
  • 原文地址:https://www.cnblogs.com/chxl800/p/14416581.html
Copyright © 2011-2022 走看看