Noelkd
Noelkd

Reputation: 7906

Update Rows based on JOIN results

I can't get the following query to work:

UPDATE ISSUE
SET DUE_DATE = DATE(ISSUE.DATE_ADDED,'+90 day')
JOIN CVE on CVE.CVE_ID = ISSUE.CVE_ID
WHERE CVE.CVSS >= 4 AND CVE.CVSS < 9

This is because in sqlite3 you can't join in an UPDATE. What I'm trying to do is set the due date of an issue to be 90 days after the date added if the CVE associated with the issue is: greater than or equal to four and less than 9. Is there an alternative option that I'm missing here?

Upvotes: 0

Views: 62

Answers (1)

Paras
Paras

Reputation: 642

You can join the rows in a sub-query.

UPDATE ISSUE
SET DUE_DATE = DATE(ISSUE.DATE_ADDED,'+90 day')
WHERE ISSUE.CVE_ID IN (
  SELECT ISSUE.CVE_ID
  FROM ISSUE JOIN CVE on CVE.CVE_ID = ISSUE.CVE_ID
  WHERE CVE.CVSS >= 4 AND CVE.CVSS < 9
)

Upvotes: 1

Related Questions