1、建表语句
CREATE TABLE `tb_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`sex` varchar(10) DEFAULT NULL,
`datatype` varchar(2) DEFAULT NULL,
`pkfields` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
2、表数据截图
3、更新SQL
update tb_user t1
inner join (
select * from tb_user where datatype = 'bl'
) t2
on t1.datatype = 'sf' and t1.pkfields = t2.pkfields
set t1.name = t2.name, t1.age = t2.age, t1.sex = t2.sex;
4、执行更新SQL后,表数据截图