今天在执行这样一条语句
update CarModel set status=0 where id in(select m.id from CarModel m where type='cs' and NOT EXISTS(select c.modelId from Car c where c.modelId=m.id))
mysql跑出来这样子一个错误
Table 'CarModel' is specified twice, both as a target for 'UPDATE' and as a separate source for data
改成这个就可以了
update CarModel set status=0 where id in(select * from (select m.id from CarModel m where type='cs' and NOT EXISTS(select c.modelId from Car c where c.modelId=m.id)) as temp)