将数据库字段1改为2,2改为1
- 使用中间变量
update table set target='3' where target='1';
update table set target='1' where target='2';
update table set target='2' where target='3';
- 使用case语句
update table
SET target=
CASE target
WHEN '1' THEN '2'
WHEN '2' THEN '1'
END