How to update 'date_from' (t1) using 'modfied' (t2) when it is like 20/07/20.
So in this case in t1 id's 1 and 2 are to be updated and id 3 stays.
Table 1:
id date_from
-----------------------
1 13/07/30
2 13/07/30
3 13/07/30
Table 2:
id name modified
-----------------------
1 x 20/07/20
2 y 20/07/20
3 z 19/05/10
You know in advance which value needs to be assigned, so you just need to filter which rows should be updated. exists
seems sufficient:
update t1
set date_from = date '2020-07-20'
where exists (
select 1 from t2 where t2.id = t1.id and t2.modified = date '2020-07-20'
)