I have 3 tables named table1 table2 and table3 . table3 contains records that have table1.id and table2.id and some other columns. Therefore, I need to do the following. for each record in table 1, I need to see if there is a row in table3 containing this table1.id and any other table2.id, if there is no such record, I want to insert it.
so here is an example.
suppose table1
1 ... ... ... 2 ... ... ...
table 2
10 .. .. .. 20 .. .. ..
Table3
1 | 10 .. .. .. 2 | 20 .. .. ..
I need to add
1 20 .. .. .. and 2 10 .. .. .. rows in table3, because for table1.id 1 it did not have a row that had all table2.id (in this case 20), and for table1.id 2 also did not have a row that had all table2.id (in this case 10). any help would be appreciated
source share