今天在執行這樣一條語句mysql
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跑出來這樣子一個錯誤sql
Table 'CarModel' is specified twice, both as a target for 'UPDATE' and as a separate source for data code
改爲這個就能夠了ci
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)