I have a many to many relation table in which I need to insert rows.
Suppose the headers Are:
Table1: Id_1 | Etc....
Table2: Id_2 | Etc....
Relation_Table: Id_1 | Id_2 | Etc.
I need to do the following:
- Insert a new element in table 1
- Link this new element to all elements in table 2
So, I need to add in the relation table, n rows as the following:
(id_1_new, id_2_0),
(id_1_new, id_2_1),
(id_1_new, id_2_2),
(id_1_new, id_2_3),
(id_1_new, id_2_4),
(id_1_new, id_2_5),
(id_1_new, id_2_6),....
- Where
id_1_new
is known and may be entered manually - And
id_2_n
may come fromselect Id_2 from Table2
.
How can I do this using SQL statements? Microsoft Access solutions are welcome as well.