Update with a subquery and a join

How do I update table1 with results of this query -

select b.description from 
table1 c
join 
(
    SELECT distinct a.hcpc, a.description
    FROM table2 a 
) b 
on b.hcpc = c.hcpc
where c.description = '0'

I want to do something like this -

update table1 
set table1.description = (select b.description from table1 c
join 
(
    SELECT distinct a.hcpc, a.description
    FROM table2 a 
) b 
on b.hcpc = c.hcpc
where c.description = '0'
) 


Read more here: https://stackoverflow.com/questions/67927549/update-with-a-subquery-and-a-join

Content Attribution

This content was originally published by Aaron at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: