MySQL Forums :: InnoDB :: Inseret records from one table to many


Advanced Search

Re: Inseret records from one table to many
Posted by: Peter Brawley ()
Date: March 23, 2017 11:24AM

> it insert the category only and not the parent_category

That's exactly what ...

INSERT INTO t_category (category)
SELECT category from t_csv where category NOT IN (select category from t_category

... says to do.

If you want also to insert t_cv.parent_category, you need something like ...

insert into t_category (category, parent_category)
select category, parent_category
from t_csv
where category not in (select category from t_category)

Options: ReplyQuote


Subject Views Written By Posted
Inseret records from one table to many 69 atjun yadav 03/23/2017 06:37AM
Re: Inseret records from one table to many 38 Peter Brawley 03/23/2017 11:24AM
Re: Inseret records from one table to many 41 atjun yadav 03/23/2017 12:37PM
Re: Inseret records from one table to many 67 Peter Brawley 03/23/2017 01:18PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.