I have two existing tables with data populated
table A
–tableA_id
–contentA
table B
–tableB_id
–contentB
Now, I want to create a many to many relationship table
table A_B
–tableA_id
–tableB_id
the question is that how to write a sql script (I am new to sql) to populate table A_B using the existing data from table A and table B. Many thanks,
Mark
If you want to populate table A_B, you’d have to do this:
CROSS JOIN will relate each row in table A with each row in table B.
If you want to relate some rows in table A with some rows in table B, you need to be more specific, and do something like: