您的位置:首页 > 数据库 > MySQL

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

2018-01-27 00:00 681 查看
今天在执行这样一条语句

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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql
相关文章推荐