请看一下我在 MySql Workbench 中写的这条语句:
update customer set flag = 1
where id in (select id from customer
group by phoneNumber
having count(phoneNumber) > 1);
显示以下消息:
Error Code: 1093. You can't specify target table 'customer' for update in FROM clause
我做错了什么?
最佳答案
尝试一下:
update customer set flag = 1
where id in (select * from (select id from customer
group by phoneNumber
having count(phoneNumber) > 1)t ) ;
关于带子查询的 MySql 更新语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24436549/