mysql报Table 'XXX' is specified twice, both as a target for 'UPDATE'....

今天在执行这样一条语句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)
相关文章
相关标签/搜索