sql-updatemulti-table

Update table if value in another table is met


I have two tables: one is called PMWO and the other table is called PMWO_DTL

PMWO has a field named ARCHIVED

PMWO_DTL has a field named WO_OPEN

I need to set ARCHIVED to 'Y' when WO_OPEN equals 'N'

the two tables can be linked by the ID's

PMWO.ID

and

PMWO_DTL.PMWO_ID

Please and thank you.

Bas


Solution

  • I guess, you can try the below code :

    update PMWO set ARCHIVED='Y' where PMWO.ID in (select distinct PMWO_DTL.PMWO_ID from PMWO_DTL where WO_OPEN ='N');

    Let me know if it works