안녕하세요
백업 테이블을 가지고 테이블의 특정 칼럼을 갱신하려고 다음 과 같은 SQL을 작성하였습니다.
그런데 갱신하려고 하는 칼럼이 not null column이라서 매칭되지 않는 레코드의 경우에는 에러를 발생시킵니다.
매칭되지 않는 레코드는 그냥 그대로 원래 레코드를 insert하고자 하는 경우에는 어떻게 해야 하나요?
INSERT INTO tbl_abc SELECT a.item01 ,b.true_item02 --not null column ,c.true_item03 ,a.item04 ,a.item05 FROM tbl_abc_bk a -- tbl_abc backup table LEFT JOIN ( SELECT distinct false_item02 ,true_item02 FROM recovery_tbl_abc ) b ON a.item02 = b.false_item02 LEFT JOIN ( SELECT distinct false_item03 ,true_item03 FROM recovery_tbl_abc ) c ON a.item03 = c.false_item03 ;