最近接触mysql。加上有段时间没敲代码,感觉没印象了。今天按要求要处理些数据。遇到这个错误:You can't specify target table 'characters ' for update in FROM clause。虽然我也问了度娘,很多同通道中人也遇到过。大概解决办法就是创建零时表,反正就是子语句不能是同一张表。我的mysql是5.5版的。大家都说等他升级。猴年马月。。下面是我写的sql。语句的意思你懂的。希望好心人能帮帮我这个小菜鸟。先谢谢啦。update ecs_goods_attr set attr_value='白色系' where (goods_id in (select b.goods_id from ecs_goods_attr as b where b.attr_value like '%Egret%'and b.attr_id=212) ) and attr_id=245
MySQL

解决方案 »

  1.   

    update ecs_goods_attr a inner join (select goods_id from ecs_goods_attr where attr_value like '%Egret%'and b.attr_id=212) b
    on a.goods_id=b.goods_id  
    set attr_value='白色系' 
    where  attr_id=245
      

  2.   

    还是不行。提示这个错误。。Unknown column 'b.attr_id' in 'where clause' 。
      

  3.   

    update ecs_goods_attr a inner join (select goods_id from ecs_goods_attr where attr_value like '%Egret%'and attr_id=212) b
    on a.goods_id=b.goods_id  
    set attr_value='白色系' 
    where  attr_id=245