M
M
Manu_habr2020-12-07 20:51:21
MySQL
Manu_habr, 2020-12-07 20:51:21

How to copy data from 2 tables into one?

INSERT into archive (title_product, title_category, price_product) 

SELECT title from product, 
SELECT title from category, 
SELECT price from product;


Separately insert and select work. How to merge into one request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexalexes, 2020-12-07
@Manu_habr

Correctly build a selection from the desired tables.

INSERT into archive (title_product, title_category, price_product) 
SELECT p.title, c.title, p.price
  from product p
   join category c on p.category_id = c.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question