Mysql datatasbe查询中的批量更新
我有一个问题,我试图更新批量更新,以替换anotehr列中一列的值 下面是我从下面的查询生成的数据Mysql datatasbe查询中的批量更新,mysql,Mysql,我有一个问题,我试图更新批量更新,以替换anotehr列中一列的值 下面是我从下面的查询生成的数据 ID CodeID credit Image creator 47774 5635 none 5635.jpg Freshy 47790 5643 none 5643.jpg Fresh 47792 5643 none 5643AB.jpg Fresh 47793 5643 none 56
ID CodeID credit Image creator
47774 5635 none 5635.jpg Freshy
47790 5643 none 5643.jpg Fresh
47792 5643 none 5643AB.jpg Fresh
47793 5643 none 5643FF.jpg Fresh
47795 5643 none 56431.jpg Fresh
47796 5643 none 56434B.jpg Fresh
最后一列{Creator}来自下面的联接:
我想把creator的值填在credit列中,相同到相同,怎么能做到呢
select mp.id, codeid, credit, image, creator
from mp inner join mm on mm.id = mp.codeid
where credit = 'none'
像这样尝试更新
update mp SET credit = (select creator
from mp inner join mm on mm.id = mp.modid
where credit = 'none')
最终得到一个错误:
[Err] 1093 - You can't specify target table 'mods_pics_copy' for update in FROM clause
可能有某种方法可以做到这一点使用此语法
UPDATE mp
JOIN mm ON mm.id = mp.codeid AND credit = 'none'
SET mp.credit = mm.creator;
错误在集合中:
这里必须输入列名,而不是条件
更新mp集合columnname,其中credit=somecondition