I am trying to run the below query but its throwing error ERROR: multiple updates to a row by the same query is not allowed. Can anyone pls help what I am doing wrong here.If there are duplicates in data then it should update multiple records with same value.Any suggestion what to modify in below query will be appreciated,I am new to sql not sure what i am doing wrong here
UPDATE test t1 SET
folder=t2.folder,name=t2.name,session_name=t2.session_name,
mapping_name=t2.mapping_name,
update_date=to_char(now(),'yyyy-mm-dd hh24:mi:ss')::timestamp,is_deleted='N'
FROM stg t2
WHERE t1.subject_id=t2.subject_id and t1.wf_id=t2.wf_id and
t1.instance_id=t2.instance_id
and t1.session_id=t2.session_id and t2.insert_date is null;
See simple example. Test data:
Table1
Table2
Update table1: