与子查询 MySql update 语句

标签: sql MySQL
发布时间: 2017/1/9 21:33:02
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

请看看我写在 MySql 工作台此语句︰

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

我到底做错了?

解决方法 1:

试试︰

  update customer set flag = 1
  where id in (select * from (select id from customer
  group by phoneNumber
  having count(phoneNumber) > 1)t ) ;
赞助商