php - Insert values into mysql with foreign key constraints -
i have 2 tables : 'spen_recipe' , 'spen_recipe_type' shown below
i want insert values spen_recipe , spen_recipe_type simultaneously based on pk , fk constraints.
please suggest me query.
this have tried:
insert spen_recipe (`user_id`,`recipe_name`,`recipe_title`,`recipe_type`,`cooking_time`,`preparation_time`,`serving_to`,`recipe_desc`,`recipe_photo`,`created_at`,`modified_at`,`published_at`) values ('2','recipe2','title2',(select `recipe_type_id` spen_recipe_type),'20','30','4','desc1','image1','2016-11-05 11:21:43','2016-11-05 11:22:43','2016-11-05 11:21:43');
but need suggestion on how proceed after select recipe_type_id
spen_recipe_type, cause both table has null values in columns, both empty.
should spen_recipe_type or spen_recipe first inserted?
Comments
Post a Comment