根据MySQL中的条件从另一个表更新一个表

时间:2018-06-27 11:51:09

标签: mysql sql

我想从另一个表 project_progress_detial.PPD_Progress 中更新 project_progress.project_progress 列并进行此查询

UPDATE project_progress   
set progress_percent   =
(select PPD_Progress from project_progress_detial
where project_progress.project_id =project_progress_detial.PPD_ProjID and
project_progress.project_part_no = 1) table where 

但是问题是它返回并出错

  

子查询重复一行以上

实际上,我想将我的PPD_PRogress数据移到另一个表中的Project_Progress列中。

2 个答案:

答案 0 :(得分:0)

    update project_progress 
    inner join project_progress_detial
    on project_progress.project_id=project_progress_detial.PPD_ProjID


    set project_progress.project_progress=project_progress_detial.PPD_Progress
where project_progress.project_part_no = 1

答案 1 :(得分:-1)

UPDATE table1 a, 
       table2 b 
SET a.column=b.columm 
WHERE a.column1=b.column1