Skip to content

mysql: The target table of the UPDATE is not updatable

L edited this page Apr 7, 2020 · 2 revisions

目标是批量更新目标表部分字段的数据
操作内容: 1.创建临时表

drop table if exists tempTableXXX 
create table tempTableXXX ( TEMP_ID int not null, BM  varchar(14) )

2.把数据存入临时表 3.把临时数据中的数据存入目标表

update targetTableXXX ,(select * from tempTableXXX ) b set BM=b.BM where b.TEMP_ID=targetTableXXX.ID

4.删除临时表

drop table if exists tempTableXXX 

出现问题:

The target table of the UPDATE is not updatable

原因是update的字段在targetTableXXX中不存在=.=

Clone this wiki locally