CASE STRUCTURE IN A DB2 SQL UPDATE
I need to update a value (FIELD_E) in one table based on the value in a field of a second table as long as certain conditions are met. Here is what I am working with thus far. TABLE_1.FIELD_C is a primary key TABLE_2.FIELD_D is a foreign key There is a ONE TO MANY relationship between TABLE_1.FIELD_C AND TABLE_2.FIELD_D UPDATE TABLE_1 SET TABLE_1.FIELD_E = ( CASE WHEN ( SELECT MAX(FIELD_A) FROM TABLE_1, TABLE_2 WHERE TABLE_1.FIELD_C = TABLE_2.FIELD_D AND TABLE_1.FIELD_A IS NOT NULL AND TABLE_2.FIELD_B IS NULL) = 'Y' THEN '1' WHEN ( SELECT MAX(FIELD_A) FROM TABLE_1, TABLE_2 WHERE TABLE_1.FIELD_
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.