I'm trying to create a query that will update the value of rgn_no and chp_cd within the table bue to the values of rgn_no and chp_cd within the table chapterassociation. I don't think the WHERE clause is any problems, but I'm getting the following error when I run it in:
SQL error:
ERROR: insert or update on table "bue" violates foreign key constraint "bue_chp_cd_fkey"
DETAIL: Key (chp_cd)=(CA3) is not present in table "chapter".
Any assistance is greatly appreciated!
SQL Query:
UPDATE bue SET
rgn_no = chapterassociation.rgn_no,
chp_cd = chapterassociation.chp_cd
FROM
chapterassociation
WHERE
bue.mbr_no IS NULL AND bue.chp_cd IS NULL
AND bue.work_state = chapterassociation.work_state
AND bue.bgu_cd = chapterassociation.bgu_cd