Page 1 of 1

Need to insert two columns from one table another only if th

Posted: Fri May 02, 2014 2:43 am
by barb woolums
I want to enhance this mysql sql statement so that the two columns are only inserted if they don't already exist as a pair in the table.

insert into ingredient_owner (ingredient,owner) select distinct ing, (select owner from recipe where id=recipe_ing.recipe) as owner from recipe_ing where ing is not null;

Re: Need to insert two columns from one table another only i

Posted: Fri May 02, 2014 6:40 am
by Celauran
Wouldn't a composite index be the easiest solution?

Re: Need to insert two columns from one table another only i

Posted: Fri May 02, 2014 7:32 pm
by barb woolums
Done - thanks