K
K
klinnov2017-03-02 18:27:32
MySQL
klinnov, 2017-03-02 18:27:32

How to write the following query?

Hey! There are two tables and a link between them. The tables are filled except for the connecting one. You need to write a code that will fill the linking table in this form (that is, it will pull data from two tables and insert it into the one that links, since there is a lot of data and it will take a very long time by hand):
--id_product--id_curencies--active--
--1 --1--1--
--1--2--1--
--2--1--1--
--2--2--1--
active - always 1.
Thank you!
UPD: Possibly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-03-02
@klinnov

insert into m2m_table select p.id, c.id, 1 from products as p join currencies as c;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question