update with multiple inner joins in db2

Viewed 230

I have the following query

UPDATE mainList
INNER JOIN custToList D
    ON l.custToList_id = d.custToList_id
INNER JOIN dealert dt
    ON d.dealert_id = dt.dealert_id
INNER JOIN markList m
    on m.markList_id = d.markList_id
SET EXPIRATION_TIMESTAMP = CURRENT_TIMESTAMP
where dt.custNum = 2;

BUt it's telling me the first 'inner' is not valid? Can you not do inner joins on updates in db2?

1 Answers

I don't think DB2 supports JOIN in UPDATE. In your case, this is easily fixed by moving the filtering to the WHERE clause:

UPDATE mainList l
    SET EXPIRATION_TIMESTAMP = CURRENT_TIMESTAMP
WHERE EXISTS (SELECT 1
              FROM custToList D INNER JOIN
                   dealert dt
                   ON d.dealert_id = dt.dealert_id INNER JOIN
                   markList m
                   ON m.markList_id = d.markList_id
              WHERE l.custToList_id = d.custToList_id AND dt.custNum = 2
             );
Related