现在我想删除id为1的配方及其所有成分,这意味着首先我必须看看哪些成分被分配给recipeID 1 ...如何在这种情况下获得这些ID 1,2和3从FKRecipesIngredients表中存储它们并将它们存储在int []数组中,以便我可以使用这些值从Ingredient表中删除它们并最终从Recipe表中删除配方?解决方案 如果链接并级联sql中的关系,当你删除主键时它将删除所有关系自动化卡利。 So I have got 3 tables, 1 of them is a relation table with 2 foreign keys set up like so:Recipes---FKRecipesIngredients---IngredientsSay that recipe with ID 1 has 3 ingredients assigned to it, then the FK table would look like so:RecipeID 1 -- IngredientID 1RecipeID 1 -- IngredientID 2RecipeID 1 -- IngredientID 3Now I want to delete recipe with id 1 and all the ingredients with it, meaning first I have to see which ingredients are assigned to recipeID 1... how do I get those ID's in this case 1, 2 and 3 from the FKRecipesIngredients table and store them in a int[] array so that I can use those values to delete those from the Ingredient table and eventually delete the recipe from the Recipe table? 解决方案 If you link and cascade the relation in sql, when you delete the primary key it will delete all the relations automatically. 这篇关于如何在数组中存储数据库中的多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 05:57