Reputation: 37
I have 2 tables, table1 and table2.
table1 has 2 columns: status and id
and table2 has 2 columns: id and name
I have a function that receives a name and I want to update table1.status to be 0 where table1.id = table2.id and table2.name = the name I receive.
I tried looking around but every query I have tried has failed.
Upvotes: 0
Views: 40
Reputation: 1270793
You can use update
:
update table1 t1
set status = 0
where exists (select 1
from table2 t2
where t2.id = t1.id and t2.name = :name
);
Upvotes: 1