使用到的函数

  • 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 = '数据库名' ;
 

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-06-01
相关资源
相似解决方案