DROP TABLE IF EXISTS `salary
`;
CREATE TABLE `salary
` (
`id
`int(11) NOT NULL,
`name
`varchar(10) NOT NULL,
`sex
`varchar(10) NOT NULL,
`salary
` int(11) NOT NULL,
PRIMARYKEY
(`id
`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
;
INSERT INTO `salary
` VALUES ('1', 'A', 'm','2500');
INSERT INTO `salary
` VALUES ('2', 'B', 'f','1500');
INSERT INTO `salary
` VALUES ('3', 'C', 'm','5500');
INSERT INTO `salary
` VALUES ('4', 'D', 'f','500');
update salary
set sex
= if(sex
= 'm', 'f','m');
UPDATE salary
SET sex
= (CASE WHEN sex
= 'm' THEN 'f' ELSE 'm' END)
转载请注明原文地址:https://blackberry.8miu.com/read-1043.html