627. 交换工资(MySQL)(如何按条件修改数据)

1 题目

在这里插入图片描述

2 MySQL

2.1 方法一()

update salary
set sex = (
    case sex
        when 'm' then 'f'
        when 'f' then 'm'
    end);

3 如何按条件修改数据?

3.1 方法一:case when then

updateset= (
    casewhen1 then2
        when2 then1
        else3
    end);

补充:update用法
注意等号“=”

update 表名
set 列名 = 修改后的值;
发布了131 篇原创文章 · 获赞 0 · 访问量 2251

猜你喜欢

转载自blog.csdn.net/weixin_43969686/article/details/105727715