Mysql错误:1093

时间:2016-11-20 19:33:52

标签: mysql

请帮帮我。 练习是: "修改数据库,以便每场比赛得分超过3个目标的所有球员的薪水增加5%。" 我该怎么做呢?我尝试使用此代码,但他正在给出错误

 update tbplayer
 set salary_player=(salary_player*1.0)
 where tbplayer.name_player in (
 select tbjplayer.name_player
 from tbjplayer inner join tbplay
 on tbplayer.cod_player = tbplay.cod_player
 where tbplay.numberGoalsPlayer >= 3)   

表格结构: http://textuploader.com/d5vlh

错误代码:1093。您无法指定目标表' tbjogador'用于FROM子句0.000秒的更新

1 个答案:

答案 0 :(得分:0)

您无法更新用于选择所需值的表格,但您可以强制mysql为此创建一个临时表格

    update tbplayer

      set salary_player=(salary_player*1.0)
      where tbplayer.name_player in ( select t.my_name  from ( 

            select tbjplayer.name_player my_name
            from tbjplayer inner join tbplay
            on tbplayer.cod_player = tbplay.cod_player
            where tbplay.numberGoalsPlayer >= 3)  t )