Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql datatasbe查询中的批量更新_Mysql - Fatal编程技术网

Mysql datatasbe查询中的批量更新

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

我有一个问题,我试图更新批量更新,以替换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    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