mysql - Update Orphan Records using Join -
i got 2 tables below. ideally table2.c1
foreign key of table1.c1
foreign key not setup initially. not able setup foreign key because there orphan records exists in table2. want update orphan records column null.
note: not want use sub/nested query
table1 -------- | c1 | -------- | 1 | | 2 | | 3 | | 4 | |------| table2 --------------- | c1 | c3 | --------------- | 1 | | | 1 | b | | 8 | c | | 9 | d | | 2 | e | |------|------|
i want update table2.c1
null records 8
, 9
.
i don't see how want without subquery, since can't join on rows in table1 don't exist...
Comments
Post a Comment