MySQL Forums
Forum List  »  InnoDB

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
Re: Inseret records from one table to many
153
March 23, 2017 11:24AM


Sorry, you can't reply to this topic. It has been closed.

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.