The database uses db2, which has two tables: Check table (STUDY_TBL) and filter table (SELECTION_TBL)
========================================
The description of STUDY_TBL is roughly as follows:
STUDY_LID integer primary key,
STUDY_DATE DATE
......
The definition of SELECTION_TBL is roughly as follows:
SELECTION_LID integer primary key,
STUDY_LID INTEGER,
STUDY_DATE
......
============================================
STUDY_LID is not unique in SELECTION_TBL. Now we want to update all STUDY_DATE in SELECTION_TBL to be the same as STUDY_DATE in STUDY_TBL (that is, in the two tables, STUDY _ and LID are the same, STUDY_DATE in SELECTION_TBL must be the same as STUDY_DATE in STUDY_TBL ).
The SQL statement is as follows:
Update pacs. SELECTION_TBL SEL
SET STUDY_DATE = (select st. STUDY_DATE
From pacs. STUDY_TBL ST
Where st. STUDY_LID = SEL. STUDY_LID)
WHERE EXISTS
(SELECT 1 from pacs. STUDY_TBL ST1 WHERE ST1.STUDY _ LID = SEL. STUDY_LID)
PACS is the mode name. We will discuss the usage of exists in detail in future articles ....