I need to update a certain alert on a loan where the obligor and obligation is something, but I can’t figure out what I’m doing wrong in the join. This seems to update all alerts in the table rather than the specific one I want. We are using postgresql db
x
update alert set deadline = '08/09/2021'
from alert as a
where loan.obligor = 'ALERT-TEST-SIMPLE-DATA-ISSUE'
join loan on loan.id = a.loan_id
where obligor = 'ALERT-TEST-SIMPLE-DATA-ISSUE' );
Advertisement
Answer
Workbench usually refers to MySQL. If so, then the correct syntax is:
update alert a join
loan l
on l.id = a.loan_id
set a.deadline = '2021-08-09' -- or whatever the date is
where l.obligor = 'ALERT-TEST-SIMPLE-DATA-ISSUE' ;
In Postgres, this would look like:
update alert a
set a.deadline = '2021-08-09' -- or whatever the date is
from loan l
where l.id = a.loan_id and
l.obligor = 'ALERT-TEST-SIMPLE-DATA-ISSUE' ;