mysql经典笔记

来源:互联网 发布:淘宝太坑图片 编辑:程序博客网 时间:2024/06/07 15:33

1、在字段值的基础上加1:

update table set  field1 = field1+1 where id = 1;

2、在字段值基础上加字符串:

update table set field1 = concat(field1,'string') where id =1;

3、删除字段值的子字符串:

update table set field1 =  replace(field1,'substring','') where id =1;

4、case 语句:

update table set field1 = (CASE ISNULL(field1) OR field = '' WHEN 1 THEN '新值' ELSE '另一新值' END) where id= 1;

0 0
原创粉丝点击