mysql - Delete 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 delete before applying alter statement.

note: not want use sub/nested query

table1 -------- | c1   | -------- | 1    | | 2    | | 3    | | 4    | |------|  table2 -------- | c1   | -------- | 1    | | 1    | | 8    | | 9    | | 2    | |------| 

i want delete records 8 , 9 table 2.

delete table2.* table2 left outer join table1 on table2.c1 = table1.c1 table1.c1 null 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -