I currently have a Main result table (test1) that stores all of my records of issues and a second table (test2) that is run every week or so and I'm trying to find those records where not exists in the weekly update and then update the date in the main result table as that is when it got updated in the system to be corrected.
I am trying to add the records from test2
table to test1
table if they are not already in the table.
This works:
insert into table test1 (id, name, code)
select * from test2 t2 where t2.id not in (select id from test1);
I'm trying to also update table test1
'Corrected_date'
column to show current_date for all records that are found in test1
but not in test2
example data below:
Table 1
ID NAME CODE CORRECTED_DATE
1 TEST 3
29 TEST2 90
Table 2
ID NAME CODE
12 TEST5 20
1 TEST 3
Expected End Result of Table 1
ID NAME CODE CORRECTED_DATE
1 TEST 3
29 TEST2 90 3/13/2019
12 TEST5 20