我正在尝试创建一个查询,将 table 的值和内部的值更新为rgn_no
tablechp_cd
的bue
值rgn_no
和chp_cd
内部的值chapterassociation
。我认为 WHERE 子句没有任何问题,但是当我运行它时出现以下错误:
SQL错误:
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".
非常感谢任何帮助!
SQL查询:
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