1、多条记录单独更新
需求:有个表(mcs_facility_gx)的字符型字段mf_id,将里面最前面两个字符改为51,比如“45000000140011”,改为“51000000140011”。
update mcs_facility_gx mfg,(SELECT id,CONCAT('51',(substring(mf_id,3))) id2 from mcs_facility_gx) mm set mfg.mf_id = mm.id2 where mfg.id = mm.id;
2、A表插入到B表,表结构一样
insert into scorebak select * from socre where neza='neza' --插入一行,要求表scorebak 必须存在 select * into scorebak from score where neza='neza' --也是插入一行,要求表scorebak 不存在