MYSQL数据库 UPDATE和DELETE操作,where in条件报错的解决办法

时间:2025-03-20 08:17:36

#子查询(不支持)
update question q set q.`level`=2 where in( select id from  question where id>=2111 limit 165,165);


#改写
update question q inner join ( select id from  question where id>=2111 limit 165,165) t on = set q.`level`=2;


#子查询(不支持)
delete from `user` where id in (
   select min(id) as id from `user` group by wx_open_id having count(1)>1
);

#改写
delete from `user` where id in (
    select id from(    
       select min(id) as id from `user` group by wx_open_id having count(1)>1
    ) t
);