方式一
update 表名 set 字段名=case when 字段名=0 then 1 else 0 end
方式二
update 表名 set 字段名=abs(字段名-1)
示例
update students set gender = abs(gender - 1) where id = 1;
update students set gender=case when gender=0 then 1 else 0 end where id = 1;
2024-02-08 19:42:28
方式一
update 表名 set 字段名=case when 字段名=0 then 1 else 0 end
方式二
update 表名 set 字段名=abs(字段名-1)
示例
update students set gender = abs(gender - 1) where id = 1;
update students set gender=case when gender=0 then 1 else 0 end where id = 1;